/* Theme Overrides for Search Page */

.search-tabs {
    display: flex;
    gap: 20px;
    border-bottom: 1px solid var(--color-border);
    margin: 0 0 12px 0;
    padding: 0;
}

.tab {
    padding: 8px 2px;
    font-size: 0.85rem;
    font-family: "Martian Mono", monospace;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px; /* Overlap container border */
}

.tab:visited:not(.tab-active) {
    color: var(--color-text-muted);
}

.tab:hover:not(.tab-active) {
    color: var(--color-text);
}

.tab-active,
.tab-active:visited,
.tab-active:hover {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.tab:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* Light Docs RS tabs */
html[data-theme="light-docs-rs"] .tab {
    font-family: "Fira Sans", sans-serif;
}

html[data-theme="light-docs-rs"] .tab-active {
    color: var(--color-primary);
}

/* Hacker News tabs */
html[data-theme="light-hacker-news"] .search-tabs {
    border-bottom: 1px solid #828282;
}

html[data-theme="light-hacker-news"] .tab {
    font-family: Verdana, Geneva, sans-serif;
    font-size: 10pt;
    text-transform: none;
    letter-spacing: normal;
    padding: 6px 2px;
}

html[data-theme="light-hacker-news"] .tab:hover:not(.tab-active) {
    color: #ff6600;
}

html[data-theme="light-hacker-news"] .tab-active,
html[data-theme="light-hacker-news"] .tab-active:hover {
    color: #ff6600;
    border-bottom-color: #ff6600;
}

html[data-theme="light-hacker-news"] .video-thumbnail-link {
    border-radius: 0;
}

/* Dark TWIR tabs */
html[data-theme="dark-twir"] .tab {
    font-family: "Univers", sans-serif;
    text-transform: none;
    letter-spacing: normal;
}

html[data-theme="dark-twir"] .tab:hover:not(.tab-active) {
    color: #d2991d;
}

html[data-theme="dark-twir"] .tab-active,
html[data-theme="dark-twir"] .tab-active:hover {
    color: #d2991d;
    border-bottom-color: #d2991d;
}

html[data-theme="dark-twir"] .video-thumbnail-link {
    background-color: #252525;
}

html[data-theme="dark-twir"] .video-thumbnail-placeholder {
    background-color: #252525;
}

/* Light Docs RS */
html[data-theme="light-docs-rs"] .result-title a {
    color: var(--color-primary);
}

html[data-theme="light-docs-rs"] .result-title a:hover {
    text-decoration: underline;
}

html[data-theme="light-docs-rs"] .results {
    background-color: #ffffff;
    border: 1px solid var(--color-border);
}

html[data-theme="light-docs-rs"] .result-item {
    border-bottom: 1px solid #f6f8fa;
}

html[data-theme="light-docs-rs"] .result-item:hover {
    background-color: #f6f8fa;
}

/* Hacker News */
html[data-theme="light-hacker-news"] #search {
    border: 1px solid #828282;
    border-radius: 0;
    font-size: 10pt;
    font-family: Verdana, Geneva, sans-serif;
    height: auto;
    line-height: normal;
}

html[data-theme="light-hacker-news"] #search:focus {
    box-shadow: none;
}

html[data-theme="light-hacker-news"] .search-icon {
    width: 14px;
    height: 14px;
    right: 8px;
}

html[data-theme="light-hacker-news"] .results {
    background-color: #f6f6ef;
    border: none;
    border-radius: 0;
    padding: 0;
}

html[data-theme="light-hacker-news"] .result-item {
    padding: 4px 0;
    border-bottom: none;
    background-color: transparent;
}

html[data-theme="light-hacker-news"] .result-item:hover {
    background-color: transparent;
}

html[data-theme="light-hacker-news"] .result-title {
    font-size: 10pt;
    font-weight: normal;
    margin-bottom: 2px;
    font-family: Verdana, Geneva, sans-serif;
}

html[data-theme="light-hacker-news"] .result-title a {
    color: #000000;
    text-decoration: none;
}

html[data-theme="light-hacker-news"] .result-title a:visited {
    color: #828282;
}

html[data-theme="light-hacker-news"] .result-meta {
    font-size: 8pt;
    gap: 4px;
    font-family: Verdana, Geneva, sans-serif;
    text-transform: none;
    letter-spacing: normal;
}

html[data-theme="light-hacker-news"] .result-meta .domain {
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    color: #828282;
    margin-left: 4px;
    font-weight: normal;
}

html[data-theme="light-hacker-news"] .meta-item {
    color: #828282;
}

html[data-theme="light-hacker-news"] .meta-item:not(:last-child)::after {
    margin: 0 4px;
    color: #828282;
}

html[data-theme="light-hacker-news"] .discussion-link {
    color: #828282;
}

html[data-theme="light-hacker-news"] .tag {
    background-color: transparent;
    border: 1px solid #ff6600;
    color: #ff6600;
    padding: 1px 4px;
    border-radius: 2px;
    font-size: 8pt;
    font-family: Verdana, Geneva, sans-serif;
}

/* Dark TWIR */
html[data-theme="dark-twir"] .result-title {
    color: #d2991d;
    font-family: "Univers", sans-serif;
}

html[data-theme="dark-twir"] .result-title a {
    color: #d2991d;
}

html[data-theme="dark-twir"] .result-title a:hover {
    color: #d2991d;
}

html[data-theme="dark-twir"] .result-meta {
    font-family: "Univers", sans-serif;
    text-transform: none;
    letter-spacing: normal;
}

html[data-theme="dark-twir"] .meta-item {
    color: #d2991d;
}

html[data-theme="dark-twir"] .meta-item:not(:last-child)::after {
    color: rgba(210, 153, 29, 0.4);
}

html[data-theme="dark-twir"] .tag {
    background-color: rgba(210, 153, 29, 0.1);
    color: #d2991d;
    border: 1px solid rgba(210, 153, 29, 0.2);
    font-family: "Univers", sans-serif;
    text-transform: none;
    letter-spacing: normal;
}

/* General Search Styles */

.search-container {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
}

.search-input-wrapper {
    position: relative;
    flex-grow: 1;
}

#search {
    width: 100%;
    padding: 14px 20px;
    padding-right: 40px;
    font-size: 0.95rem;
    font-family: "Univers", sans-serif;
    background-color: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    transition: all 0.2s ease;
}

#search:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(72, 213, 151, 0.1);
}

#search::placeholder {
    color: var(--color-text-muted);
}

.suggestions-container {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    margin-top: 4px;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.suggestions-container:empty {
    display: none;
    border: none;
    box-shadow: none;
}

.suggestions-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.suggestion-item {
    padding: 10px 20px;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--color-text);
    transition: background-color 0.1s ease;
}

.suggestion-item:hover,
.suggestion-item:focus {
    background-color: rgba(72, 213, 151, 0.1);
    outline: none;
}

.search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--color-text-muted);
    cursor: pointer;
    background: transparent;
    border: none;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-icon:hover {
    color: var(--color-primary);
}

/* Active filters display */

/* Results */
.results {
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 0;
    background-color: var(--color-surface);
}

.result-item {
    padding: 32px;
    border-bottom: 1px solid var(--color-border);
    transition: background-color 0.15s ease;
}

.result-item:hover {
    background-color: rgba(72, 213, 151, 0.015);
}

.result-item:last-child {
    border-bottom: none;
}

/* Video Result Card */
.result-item-video,
.result-item-talk {
    display: flex;
    gap: 20px;
}

.video-thumbnail-link {
    flex-shrink: 0;
    width: 293px;
    position: relative;
    overflow: hidden;
    border-radius: 4px;
    background-color: var(--color-surface);
    /* 16:9 aspect ratio using padding trick */
    padding-bottom: 165px; /* 293px * 0.5625 = 165px for 16:9 */
}

.video-thumbnail-wrapper {
    position: absolute;
    top: -16.75%;
    left: 0;
    right: 0;
    bottom: -16.75%;
}

.video-thumbnail {
    width: 100%;
    display: block;
}

.video-thumbnail-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--color-border);
}

.video-thumbnail-placeholder svg {
    width: 32px;
    height: 32px;
    color: var(--color-text-muted);
}

/* Play button overlay */
.video-play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition:
        background-color 0.2s ease,
        transform 0.2s ease;
    pointer-events: none;
}

.video-play-overlay svg {
    width: 20px;
    height: 20px;
    color: #fff;
    margin-left: 3px; /* Optical centering for play icon */
}

.video-thumbnail-link:hover .video-play-overlay {
    background-color: rgba(0, 0, 0, 0.85);
    transform: translate(-50%, -50%) scale(1.1);
}

.video-duration {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background-color: rgba(0, 0, 0, 0.8);
    color: #fff;
    font-size: 0.7rem;
    font-family: "Martian Mono", monospace;
    padding: 2px 4px;
    border-radius: 2px;
}

/* Podcast Result Card */
.result-item-podcast {
    display: flex;
    gap: 20px;
}

.podcast-thumbnail-link {
    flex-shrink: 0;
    width: 160px;
    height: 160px;
    position: relative;
    overflow: hidden;
    border-radius: 6px;
    background-color: var(--color-surface);
    aspect-ratio: 1 / 1;
}

.podcast-thumbnail-wrapper {
    position: absolute;
    inset: 0;
}

.podcast-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.podcast-thumbnail-placeholder {
    width: 100%;
    height: 100%;
    background-color: var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
}

.podcast-thumbnail-placeholder svg {
    width: 32px;
    height: 32px;
    color: var(--color-text-muted);
}

.podcast-play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition:
        background-color 0.2s ease,
        transform 0.2s ease;
    pointer-events: none;
}

.podcast-play-overlay svg {
    width: 18px;
    height: 18px;
    color: #fff;
    margin-left: 2px;
}

.podcast-thumbnail-link:hover .podcast-play-overlay {
    background-color: rgba(0, 0, 0, 0.85);
    transform: translate(-50%, -50%) scale(1.05);
}

.podcast-duration {
    position: absolute;
    bottom: 6px;
    right: 6px;
    background-color: rgba(0, 0, 0, 0.8);
    color: #fff;
    font-size: 0.7rem;
    font-family: "Martian Mono", monospace;
    padding: 2px 4px;
    border-radius: 2px;
}

.result-content {
    flex: 1;
    min-width: 0;
}

.result-title {
    color: var(--color-text);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 8px;
    font-family: "Univers", sans-serif;
}

.result-title a {
    color: var(--color-text);
    text-decoration: none;
    transition: color 0.2s ease;
}

.result-title a:hover {
    color: var(--color-primary);
}

.podcast-byline {
    display: flex;
    flex-wrap: wrap;
    column-gap: 10px;
    row-gap: 4px;
    margin: -2px 0 10px;
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

.podcast-byline-item {
    display: inline-flex;
    align-items: center;
    white-space: normal;
}

.podcast-byline-item:not(:last-child)::after {
    content: "•";
    margin: 0 6px;
    color: var(--color-border);
}

.result-snippet {
    color: var(--color-text);
    margin-bottom: 12px;
    font-size: 0.95rem;
    text-wrap: wrap;
    text-overflow: ellipsis;

    /* Break up long strings */
    overflow-wrap: break-word; /* Modern browsers */
    word-wrap: break-word; /* Legacy */
    word-break: break-word; /* For non-CJK text */
    max-width: 100%;
}

.result-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    row-gap: 6px;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: 12px;
    font-family: "Martian Mono", monospace;
    letter-spacing: 0.05em;
}

.meta-item {
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
    font-size: 0.75rem;
    font-weight: 400;
}

.meta-item:not(:last-child)::after {
    content: "|";
    margin: 0 8px;
    color: var(--color-border);
}

.domain-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    margin-right: 6px;
}

.domain-icon svg {
    width: 100%;
    height: 100%;
    stroke: var(--color-primary);
}

.icon-audio {
    background-image: var(--icon-audio);
}

.icon-website {
    background-image: var(--icon-website);
}

.tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.tag {
    background-color: transparent;
    color: var(--color-primary);
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    font-family: "Martian Mono", monospace;
    text-transform: none;
    letter-spacing: 0.02em;
    border: 1px solid var(--color-border);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.tag:hover {
    background-color: rgba(72, 213, 151, 0.05);
    border-color: var(--color-primary);
    cursor: pointer;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 32px;
    margin-top: 20px;
}

.pagination-btn {
    padding: 8px 16px;
    background-color: transparent;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.9rem;
    font-family: "Martian Mono", monospace;
    transition: all 0.2s ease;
}

.pagination-btn:hover:not(.disabled) {
    border-color: var(--color-primary);
    background-color: rgba(72, 213, 151, 0.05);
}

.pagination-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.pagination-info {
    font-family: "Martian Mono", monospace;
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

/* Easter Egg */
.quote-easter-egg {
    padding: 32px;
    border-top: 1px solid var(--color-border);
    text-align: center;
}

.quote-content {
    font-size: 0.95rem;
    font-style: italic;
    color: var(--color-text-muted);
    margin-bottom: 12px;
    line-height: 1.6;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.quote-attribution {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    font-family: "Martian Mono", monospace;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.quote-attribution a {
    color: inherit;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
}

.quote-attribution a:hover {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

@media (max-width: 768px) {
    .search-tabs {
        gap: 16px;
        margin: 0 0 10px 0;
    }

    .tab {
        padding: 6px 2px;
        font-size: 0.8rem;
    }

    .result-item {
        padding: 20px;
    }

    .result-item-video,
    .result-item-talk {
        flex-direction: column;
        gap: 12px;
    }

    .video-thumbnail-link {
        width: 100%;
        padding-bottom: 56.25%;
    }

    .result-item-podcast {
        flex-direction: column;
        gap: 12px;
    }

    .podcast-thumbnail-link {
        width: 100%;
        max-width: 320px;
        height: 320px;
    }

    .pagination {
        padding: 20px;
        justify-content: center;
        flex-wrap: wrap;
    }

    #search {
        font-size: 16px; /* Prevents auto-zoom on iOS */
    }

    @media (max-width: 600px) {
        .search-container {
            position: sticky;
            top: 0;
            z-index: 100;
            background-color: var(--color-background);
            margin-left: -16px;
            margin-right: -16px;
            padding: 12px 16px;
            margin-bottom: 8px;
            border-bottom: 1px solid var(--color-border);
            box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
        }

        .search-tabs {
            gap: 12px;
            margin: 0 0 8px 0;
        }

        .tab {
            padding: 4px 0;
            font-size: 0.75rem;
        }
    }
}
