/*
 * Site-wide search and the 404 page.
 * Loaded on is_search() and is_404() only (inc/search.php). Everything reads
 * the colour chooser's tokens, so light and dark mode and every site colour
 * scheme come for free. The colour chooser paints links with !important, which
 * is why the chips and options repeat theirs.
 */

.screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --- The form ------------------------------------------------------------ */

.rt-search {
    position: relative;
    max-width: 640px;
    margin: 0 auto;
    text-align: left;
}

.rt-search__field {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--form-bg, var(--bg-color, #fff));
    border: 1px solid var(--border-color, #cfcfcf);
    border-radius: 999px;
    box-shadow: 0 2px 14px var(--shadow-color, rgba(0, 0, 0, 0.08));
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.rt-search__field:focus-within {
    border-color: var(--focus-color, var(--button-color, #333));
    box-shadow: 0 0 0 3px var(--focus-shadow, rgba(0, 0, 0, 0.12)), 0 2px 14px var(--shadow-color, rgba(0, 0, 0, 0.08));
}

.rt-search__icon {
    position: absolute;
    left: 1.1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.3rem;
    line-height: 1;
    color: var(--h2-color, var(--text-color, #333));
    opacity: 0.7;
    pointer-events: none;
}

.rt-search__input,
.rt-search__input:focus {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    padding: 0.95rem 0.75rem 0.95rem 3rem;
    border: 0 !important;
    border-radius: 999px;
    background: transparent !important;
    color: var(--form-text, var(--text-color, #222)) !important;
    font: inherit;
    font-size: 1.05rem;
    line-height: 1.3;
    outline: none;
    box-shadow: none !important;
    -webkit-appearance: none;
    appearance: none;
}

.rt-search__input::-webkit-search-decoration,
.rt-search__input::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
}

.rt-search__input::placeholder {
    color: var(--form-text, var(--text-color, #222));
    opacity: 0.5;
}

.rt-search__submit {
    flex: none;
    margin: 0.3rem 0.3rem 0.3rem 0;
    padding: 0.65rem 1.25rem;
    border: 0;
    border-radius: 999px !important;
    background: var(--button-color, #333);
    color: var(--button-color-font, #fff) !important;
    font: inherit;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.rt-search__submit:hover,
.rt-search__submit:focus-visible {
    background: var(--button-color-hover, var(--button-color, #333));
    color: var(--button-color-font-hover, var(--button-color-font, #fff)) !important;
}

.rt-search__submit:active {
    transform: scale(0.97);
}

/* --- Suggestions --------------------------------------------------------- */

.rt-search__panel {
    position: absolute;
    box-sizing: border-box; /* the JS height cap includes padding and border */
    top: calc(100% + 0.5rem);
    left: 0;
    right: 0;
    z-index: 1000;
    padding: 0.5rem;
    max-height: min(60vh, 520px);
    overflow-y: auto;
    background: var(--bg-color, #fff);
    border: 1px solid var(--border-color, #cfcfcf);
    border-radius: 18px;
    box-shadow: 0 16px 40px var(--shadow-color-hover, var(--shadow-color, rgba(0, 0, 0, 0.18)));
    scrollbar-width: thin;
}

.rt-search__panel[hidden] {
    display: none;
}

.rt-search__group + .rt-search__group {
    margin-top: 0.35rem;
    padding-top: 0.35rem;
    border-top: 1px solid var(--border-color-subtle, var(--border-color, #e5e5e5));
}

.rt-search__group-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.75rem 0.25rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--h2-color, var(--text-color, #333));
    opacity: 0.75;
}

.rt-search__option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    border-radius: 12px;
    color: var(--text-color, #222) !important;
    text-decoration: none !important;
    cursor: pointer;
}

.rt-search__option:hover,
.rt-search__option[aria-selected="true"] {
    background: var(--another-shade, rgba(128, 128, 128, 0.12));
}

.rt-search__thumb {
    flex: none;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    overflow: hidden;
    background: var(--another-shade, rgba(128, 128, 128, 0.12));
    color: var(--h2-color, var(--text-color, #333));
    font-size: 1.35rem;
}

.rt-search__thumb img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
}

.rt-search__text {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.rt-search__title {
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rt-search__meta {
    font-size: 0.82rem;
    opacity: 0.7;
}

.rt-search mark,
.rt-search-page mark {
    background: transparent;
    color: var(--h1-color, inherit);
    font-weight: 700;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 2px;
}

.rt-search__terms {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0.25rem 0.75rem 0.5rem;
}

.rt-search__more {
    display: block;
    margin-top: 0.35rem;
    padding: 0.7rem 1rem;
    border-top: 1px solid var(--border-color-subtle, var(--border-color, #e5e5e5));
    border-radius: 0 0 12px 12px;
    text-align: center;
    font-weight: 600;
    color: var(--link-color, var(--text-color, #222)) !important;
    text-decoration: none !important;
}

.rt-search__more:hover,
.rt-search__more[aria-selected="true"] {
    background: var(--another-shade, rgba(128, 128, 128, 0.12));
}

.rt-search__empty {
    margin: 0;
    padding: 0.9rem 1rem;
    opacity: 0.75;
}

/* --- Chips (type filter, topics, quick links) ----------------------------- */

.rt-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.95rem;
    border: 1px solid var(--border-color, #cfcfcf);
    border-radius: 999px;
    background: transparent;
    color: var(--text-color, #222) !important;
    font-size: 0.92rem;
    line-height: 1.2;
    text-decoration: none !important;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.rt-chip i {
    font-size: 1.1em;
    line-height: 1;
}

.rt-chip:hover,
.rt-chip[aria-selected="true"] {
    border-color: var(--button-color, #333);
    background: var(--another-shade, rgba(128, 128, 128, 0.12));
}

.rt-chip[aria-current] {
    border-color: var(--button-color, #333);
    background: var(--button-color, #333);
    color: var(--button-color-font, #fff) !important;
}

.rt-chip--small {
    padding: 0.3rem 0.75rem;
    font-size: 0.85rem;
}

.rt-chip__count {
    font-size: 0.85em;
    opacity: 0.7;
}

/* --- Front page --------------------------------------------------------- */

.front-page-search {
    margin: 1.5rem 0 0.5rem;
}

/* --- Archives (posts, shop, events) -------------------------------------- */

.rt-archive-search {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto 1rem;
    padding: 0 5px;
    box-sizing: border-box;
}

.rt-archive-search .rt-search {
    max-width: 640px;
}

/* --- Empty archive ------------------------------------------------------ */

.rt-empty {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2.5rem 20px 4rem;
    text-align: center;
}

.rt-empty__lead {
    max-width: 560px;
    margin: 0 auto 1.75rem;
    font-size: 1.05rem;
    line-height: 1.6;
    opacity: 0.8;
}

/* --- 404 ----------------------------------------------------------------- */

.rt-404 {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.5rem 20px 4rem;
    text-align: center;
}

.rt-404__hero {
    padding: 1.5rem 0 2.5rem;
}

.rt-404__code {
    margin: 0;
    font-size: clamp(6rem, 22vw, 13rem) !important; /* the font picker sizes text with !important */
    font-weight: 800;
    line-height: 0.9;
    letter-spacing: -0.04em;
    color: transparent;
    -webkit-text-stroke: 2px var(--h1-color, currentColor);
    opacity: 0.35;
    user-select: none;
}

@supports not (-webkit-text-stroke: 1px #000) {
    .rt-404__code {
        color: var(--h1-color, currentColor);
        opacity: 0.12;
    }
}

.rt-404__title {
    position: relative;
    margin: -0.55em 0 0.6rem;
    font-size: clamp(1.6rem, 4vw, 2.4rem);
    line-height: 1.2;
    color: var(--h1-color, inherit);
}

.rt-404__lead {
    max-width: 560px;
    margin: 0 auto 1.75rem;
    font-size: 1.05rem;
    line-height: 1.6;
    opacity: 0.8;
}

.rt-section-title {
    margin: 0 0 1.25rem;
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--h2-color, inherit);
}

.rt-404__guesses {
    margin-top: 2rem;
}

.rt-404__links {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 2.5rem;
}

.rt-404__links-label {
    width: 100%;
    margin-bottom: 0.25rem;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.7;
}

/* --- Results page -------------------------------------------------------- */

.rt-search-page {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px 4rem;
}

.rt-search-page__head {
    margin-bottom: 2rem;
    text-align: center;
}

.rt-search-page__count {
    margin: 1.25rem 0 0.9rem;
    font-size: 1.05rem;
}

.rt-search-page__filter {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
}

.rt-search-page__empty {
    max-width: 560px;
    margin: 2rem auto;
    text-align: center;
}

/* the blog card, with a type mark instead of the author line */
.search-results .search-mark {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.search-results .search-mark i {
    font-size: 1.2em;
    line-height: 1;
}

.search-results .search-meta::before {
    content: "·";
    margin: 0 0.45rem 0 0.25rem;
    opacity: 0.6;
}

.search-results .search-placeholder {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    min-height: 220px;
    background: var(--another-shade, rgba(128, 128, 128, 0.12));
    color: var(--h2-color, var(--text-color, #333));
    font-size: 3.2rem;
    opacity: 0.85;
}

/* pagination (the_posts_pagination) */
.rt-search-page .navigation.pagination {
    margin-top: 2.5rem;
    text-align: center;
}

.rt-search-page .nav-links {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.35rem;
}

.rt-search-page .page-numbers {
    display: inline-flex;
    align-items: center;
    min-height: 2.4rem;
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--border-color, #cfcfcf);
    border-radius: 999px;
    color: var(--text-color, #222) !important;
    text-decoration: none !important;
    line-height: 1.2;
}

.rt-search-page a.page-numbers:hover {
    border-color: var(--button-color, #333);
    background: var(--another-shade, rgba(128, 128, 128, 0.12));
}

.rt-search-page .page-numbers.current {
    border-color: var(--button-color, #333);
    background: var(--button-color, #333);
    color: var(--button-color-font, #fff) !important;
}

.rt-search-page .page-numbers.dots {
    border-color: transparent;
}

@media (max-width: 600px) {
    .rt-search__input,
    .rt-search__input:focus {
        padding-left: 2.6rem;
        font-size: 1rem;
    }

    .rt-search__icon {
        left: 0.9rem;
        font-size: 1.15rem;
    }

    .rt-search__submit {
        padding: 0.6rem 0.9rem;
    }

    .rt-404__hero {
        padding-top: 0.5rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .rt-search__field,
    .rt-search__submit,
    .rt-chip {
        transition: none;
    }
}
