/* Search box in the site header (assets/js/site-search.js). The search index (/pagefind/) is built when the
   website publishes (tools/build-search.mjs), so it always matches the live webpages.
   Wide screens: a search field after the menu, results drop down under it.
   1099px and narrower: a search button; it opens a full-width search bar under the header. */

.nav-wrapper > .nav-links {
    margin-left: auto;
}

.site-search {
    position: relative;
    display: flex;
    align-items: center;
    margin-left: 1.5rem;
    font-family: var(--font-main, 'Roboto', system-ui, -apple-system, sans-serif);
}

.site-search svg {
    display: block;
    width: 18px;
    height: 18px;
    flex: none;
}

.site-search-toggle {
    display: none;
}

.site-search-field {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 210px;
    height: 40px;
    padding: 0 14px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.75);
    transition: width 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.site-search-field:focus-within {
    width: 280px;
    border-color: var(--color-accent, #B8860B);
    background: rgba(255, 255, 255, 0.12);
}

.site-search-input {
    flex: 1;
    min-width: 0;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    outline: none;
    background: transparent;
    color: #FFFFFF;
    font: inherit;
    font-size: 0.95rem;
    letter-spacing: 0.3px;
}

.site-search-input::placeholder {
    color: rgba(255, 255, 255, 0.7);
    opacity: 1;
}

.site-search-input::-webkit-search-cancel-button,
.site-search-input::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
}

.site-search-close {
    display: none;
}

.site-search-results {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    width: min(440px, 90vw);
    max-height: min(70vh, 560px);
    overflow-y: auto;
    padding: 6px;
    border-radius: 10px;
    background: #FFFFFF;
    color: #1A1A1A;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
    z-index: 10003;
    text-align: left;
}

.site-search-results[hidden] {
    display: none;
}

/* premium.css forces every link, span and paragraph in .topo-bg (the header) white with !important, so the
   results card needs selectors that outrank ".topo-bg a:not(.btn)". */
.site-header .site-search .site-search-result {
    display: block;
    padding: 10px 12px;
    border-radius: 8px;
    color: #1A1A1A !important;
    text-decoration: none;
    text-transform: none;
    letter-spacing: normal;
}

.site-header .site-search .site-search-result:hover,
.site-header .site-search .site-search-result.is-active {
    background: #F5F1E8;
}

.site-header .site-search .site-search-title {
    display: block;
    color: #1A1A1A !important;
    font-family: var(--font-heading, 'Outfit', system-ui, -apple-system, sans-serif);
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.3;
}

.site-header .site-search .site-search-excerpt {
    display: block;
    margin-top: 3px;
    color: #555555 !important;
    font-size: 0.85rem;
    line-height: 1.45;
}

.site-search-excerpt mark {
    padding: 0 1px;
    border-radius: 2px;
    background: rgba(184, 134, 11, 0.2);
    color: inherit;
}

.site-header .site-search .site-search-note {
    margin: 0;
    padding: 10px 12px;
    color: #666666 !important;
    font-size: 0.85rem;
    line-height: 1.45;
}

.site-header .site-search .site-search-note a {
    color: #8A6408 !important;
    text-decoration: underline;
}

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

/* The menu links sit near the top of the header row (text centered about 38px down), not at the logo's middle. */
@media (min-width: 1100px) {
    .site-search {
        align-self: flex-start;
        margin-top: 8px;
    }
}

@media (max-width: 1099px) {
    .site-search {
        position: static;
        margin-left: 1rem;
    }

    .site-search-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        padding: 0;
        border: 0;
        border-radius: 4px;
        background: transparent;
        color: #FFFFFF;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        touch-action: manipulation;
    }

    .site-search-toggle svg {
        width: 24px;
        height: 24px;
    }

    .site-search-panel {
        display: none;
        position: fixed;
        left: 0;
        right: 0;
        top: var(--site-search-top, 70px);
        padding: 12px 16px 16px;
        border-top: 1px solid rgba(255, 255, 255, 0.1);
        background: #1A1A1A;
        box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
        z-index: 10003;
    }

    .site-search.is-open .site-search-panel {
        display: block;
    }

    .site-search-field,
    .site-search-field:focus-within {
        width: 100%;
        max-width: 720px;
        height: 46px;
        margin: 0 auto;
        padding-right: 4px;
    }

    /* 16px keeps phones from zooming in when the field gets focus. */
    .site-search-input {
        font-size: 16px;
    }

    .site-search-close {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 38px;
        height: 38px;
        padding: 0;
        border: 0;
        border-radius: 999px;
        background: transparent;
        color: #FFFFFF;
        cursor: pointer;
    }

    .site-search-results {
        position: static;
        width: auto;
        max-width: 720px;
        max-height: calc(100vh - var(--site-search-top, 70px) - 96px);
        max-height: calc(100dvh - var(--site-search-top, 70px) - 96px);
        margin: 10px auto 0;
        box-shadow: none;
    }
}

@media (min-width: 769px) and (max-width: 1099px) {
    .site-search {
        align-self: flex-start;
        margin-top: 6px;
    }
}

@media (max-width: 768px) {
    .site-search {
        order: 1;
        margin-left: auto;
    }

    .mobile-toggle {
        order: 2;
        margin-left: 8px;
    }

    /* Same box as the menu button next to it. */
    .site-search-toggle {
        background: rgba(0, 0, 0, 0.5);
    }
}
