/* Throw Down Press Search Styles */
/* Mobile-first responsive design */

/* Search Container */
.search-container {
    position: relative;
    flex: 1;
    max-width: 500px;
    margin: 0 20px;
    transition: all 0.3s ease;
}

/* Expanded search mode */
.search-container.search-active {
    position: absolute;
    left: 20px;
    right: 20px;
    max-width: none;
    z-index: 1001;
}

.search-container.search-active .search-input-wrapper input {
    box-shadow: 0 0 20px rgba(207, 62, 37, 0.3);
    border-width: 3px;
}

/* Search Input Wrapper */
.search-input-wrapper {
    position: relative;
    width: 100%;
}

.search-input-wrapper input {
    width: 100%;
    padding: 10px 40px 10px 15px;
    border: 2px solid #f8c235;
    border-radius: 25px;
    background: white;
    color: #1b1915;
    font-size: 16px;
    outline: none;
    transition: all 0.3s ease;
}

.search-input-wrapper input:focus {
    border-color: #cf3e25;
    box-shadow: 0 0 10px rgba(207, 62, 37, 0.2);
}

.search-input-wrapper input::placeholder {
    color: #999;
}

/* Search Icon */
.search-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #cf3e25;
    font-size: 18px;
    pointer-events: none;
}

/* Clear Button */
.search-clear {
    position: absolute;
    right: 40px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #999;
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
    display: none;
    transition: color 0.2s ease;
}

.search-clear:hover {
    color: #cf3e25;
}

.search-input-wrapper input:not(:placeholder-shown) ~ .search-clear {
    display: block;
}

/* Search Results Container */
.search-results {
    position: absolute;
    top: calc(100% + 10px);
    left: 0;
    right: 0;
    background: white;
    border: 2px solid #f8c235;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    max-height: 80vh;
    overflow-y: auto;
    z-index: 1002;
    display: none;
}

.search-results.active {
    display: block;
}

/* Hide nav links when search is active */
header nav.search-expanded .nav-links {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

/* Hide dad joke widget when search is active */
header nav.search-expanded .dad-joke-widget {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

/* Add overlay when search is expanded */
header nav.search-expanded::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 999;
}

/* Search Results Header */
.search-results-header {
    padding: 15px 20px;
    border-bottom: 2px solid #f9f2e4;
    background: #f9f2e4;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
}

.search-results-count {
    font-weight: bold;
    color: #cf3e25;
    font-size: 14px;
}

.search-results-note {
    font-size: 12px;
    color: #666;
}

/* Search Results Grid */
.search-results-grid {
    padding: 15px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
}

/* Search Result Card */
.search-result-card {
    display: flex;
    gap: 15px;
    padding: 15px;
    background: #f9f2e4;
    border-radius: 10px;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}

.search-result-card:hover {
    border-color: #cf3e25;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(207, 62, 37, 0.2);
}

.search-result-image {
    flex-shrink: 0;
    width: 80px;
    height: 120px;
}

.search-result-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.search-result-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.search-result-title {
    font-size: 14px;
    font-weight: bold;
    color: #1b1915;
    margin: 0;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.search-result-title mark {
    background: #f8c235;
    color: #1b1915;
    padding: 0 2px;
    border-radius: 2px;
}

.search-result-author {
    font-size: 12px;
    color: #666;
    margin: 0;
}

.search-result-category {
    font-size: 11px;
    color: #cf3e25;
    font-weight: bold;
    margin: 0;
}

.search-result-link {
    display: inline-block;
    margin-top: auto;
    padding: 6px 12px;
    background: #cf3e25;
    color: white;
    text-decoration: none;
    border-radius: 5px;
    font-size: 12px;
    font-weight: bold;
    text-align: center;
    transition: background 0.2s ease;
    align-self: flex-start;
}

.search-result-link:hover {
    background: #a52f1c;
}

/* No Results */
.search-no-results {
    padding: 40px 20px;
    text-align: center;
    color: #666;
}

.search-no-results p {
    margin: 10px 0;
    font-size: 16px;
}

.search-suggestion {
    margin-top: 20px;
    font-weight: bold;
    color: #1b1915;
}

.search-suggestions {
    list-style: none;
    padding: 0;
    margin: 15px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.search-suggestions li {
    background: #f9f2e4;
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid #f8c235;
    font-size: 14px;
    color: #1b1915;
}

.search-suggestions li:hover {
    background: #f8c235;
    border-color: #cf3e25;
    transform: translateY(-2px);
}

/* Mobile Search Toggle Button */
.mobile-search-toggle {
    display: none;
    background: #cf3e25;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 25px;
    cursor: pointer;
    font-size: 18px;
    transition: background 0.2s ease;
}

.mobile-search-toggle:hover {
    background: #a52f1c;
}

/* Mobile Styles */
@media (max-width: 768px) {
    .search-container {
        position: fixed;
        top: 70px;
        left: 0;
        right: 0;
        max-width: none;
        margin: 0;
        padding: 15px;
        background: white;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
        transform: translateY(-100%);
        transition: transform 0.3s ease;
        z-index: 999;
    }

    .search-container.mobile-active {
        transform: translateY(0);
    }

    .mobile-search-toggle {
        display: block;
    }

    .search-results {
        position: fixed;
        top: 140px;
        left: 0;
        right: 0;
        max-height: calc(100vh - 150px);
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .search-results-grid {
        grid-template-columns: 1fr;
    }

    .search-result-card {
        flex-direction: row;
        gap: 12px;
    }

    .search-result-image {
        width: 100px;
        height: 150px;
        flex-shrink: 0;
    }

    .search-result-image img {
        object-fit: contain;
        object-position: center;
    }

    .search-result-link {
        align-self: flex-start;
        width: 100%;
    }
}

/* Tablet Styles */
@media (min-width: 769px) and (max-width: 1024px) {
    .search-container {
        max-width: 400px;
        margin: 0 15px;
    }

    .search-results-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}

/* Large Desktop */
@media (min-width: 1400px) {
    .search-container {
        max-width: 600px;
    }

    .search-results-grid {
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    }
}

/* Smooth Scrollbar for Results */
.search-results::-webkit-scrollbar {
    width: 8px;
}

.search-results::-webkit-scrollbar-track {
    background: #f9f2e4;
}

.search-results::-webkit-scrollbar-thumb {
    background: #f8c235;
    border-radius: 4px;
}

.search-results::-webkit-scrollbar-thumb:hover {
    background: #cf3e25;
}

/* Loading State */
.search-loading {
    padding: 40px 20px;
    text-align: center;
    color: #666;
}

.search-loading::after {
    content: '...';
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* Accessibility */
.search-input-wrapper input:focus-visible {
    outline: 3px solid #cf3e25;
    outline-offset: 2px;
}

.search-result-link:focus-visible {
    outline: 3px solid #f8c235;
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .search-container,
    .search-results {
        display: none;
    }
}
