/*
 * Shared search field (<site-search-box>, webroot/js/site-search-box.js).
 * Theme it per page by overriding the --ssb-* variables on .ssb or a parent.
 * Docs: docs/site-search-box.md
 */
.ssb {
    --ssb-accent: #4063c9;
    --ssb-accent-hover: #3454b3;
    --ssb-text: #353a40;
    --ssb-text-strong: #1f2430;
    --ssb-text-soft: #4b5160;
    --ssb-muted: #6b7280;
    --ssb-placeholder: #353a40;
    --ssb-field-bg: #f3f3f3;
    --ssb-surface: #ffffff;
    --ssb-line: #eceef3;
    --ssb-chip-line: #d9dde6;
    --ssb-active-bg: #eef2fb;
    --ssb-height: 56px;
    --ssb-radius: 28px;
    --ssb-pad-x: 24px;
    --ssb-font-size: 16px;
    --ssb-shadow-open: 0 12px 32px rgba(28, 39, 76, .16), 0 2px 6px rgba(28, 39, 76, .08);
    --ssb-ring: 0 0 0 2px rgba(64, 99, 201, .35);
    --ssb-z: 1000;
    --ssb-z-fullscreen: 1070;

    position: relative;
    width: 100%;
    min-width: 0;
    height: var(--ssb-height);
    color: var(--ssb-text);
    font-size: var(--ssb-font-size);
    line-height: 1.4;
}
.ssb--sm {
    --ssb-height: 44px;
    --ssb-radius: 22px;
    --ssb-pad-x: 18px;
    --ssb-font-size: 15px;
}
.ssb *, .ssb *::before, .ssb *::after { box-sizing: border-box; }

/* The field and its list are one card, so the outer corners never change. */
.ssb__card {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    margin: 0;
    background: var(--ssb-field-bg);
    border-radius: var(--ssb-radius);
    overflow: hidden;
    transition: background-color .15s ease, box-shadow .15s ease;
}
.ssb--focused .ssb__card {
    z-index: var(--ssb-z);
    background: var(--ssb-surface);
    box-shadow: var(--ssb-ring);
}
.ssb--open .ssb__card { box-shadow: var(--ssb-shadow-open); }

.ssb__field {
    display: flex;
    align-items: center;
    gap: 4px;
    height: var(--ssb-height);
    padding: 0 calc((var(--ssb-height) - 44px) / 2) 0 var(--ssb-pad-x);
}
.ssb--sm .ssb__field { padding-right: 3px; }

.ssb .ssb__input {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0 !important;
    outline: none;
    background: transparent;
    box-shadow: none !important;
    color: var(--ssb-text);
    font: inherit;
    font-size: var(--ssb-font-size);
    text-overflow: ellipsis;
    -webkit-appearance: none;
    appearance: none;
}
/* style.css sets a light grey ::placeholder with !important for every field. */
.ssb .ssb__input::placeholder { color: var(--ssb-placeholder) !important; opacity: 1; }
.ssb .ssb__input::-webkit-search-decoration,
.ssb .ssb__input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }

.ssb svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
    display: block;
}

.ssb__icon-btn,
.ssb__submit {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--ssb-muted);
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}
.ssb__icon-btn { width: 36px; height: 36px; }
.ssb__icon-btn svg { width: 18px; height: 18px; }
.ssb__icon-btn:hover { background: rgba(53, 58, 64, .08); color: var(--ssb-text); }

.ssb__submit {
    width: 44px;
    height: 44px;
    color: var(--ssb-text);
}
.ssb--sm .ssb__submit { width: 38px; height: 38px; }
.ssb__submit svg { width: 22px; height: 22px; }
.ssb__submit:hover { background: rgba(53, 58, 64, .08); }
.ssb__submit--ready { background: var(--ssb-accent); color: #fff; }
.ssb__submit--ready:hover { background: var(--ssb-accent-hover); color: #fff; }

.ssb__icon-btn:focus-visible,
.ssb__submit:focus-visible,
.ssb__footer-btn:focus-visible,
.ssb__footer-close:focus-visible {
    outline: 2px solid var(--ssb-accent);
    outline-offset: 2px;
}

/* Suggestions */
.ssb__panel {
    max-height: min(560px, 72vh);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0 0 10px;
}
.ssb__panel::before {
    content: "";
    display: block;
    height: 1px;
    margin: 0 var(--ssb-pad-x);
    background: var(--ssb-line);
}
.ssb__group { padding-top: 4px; }
.ssb__heading {
    padding: 12px var(--ssb-pad-x) 6px;
    color: var(--ssb-muted);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: .06em;
    line-height: 1.3;
    text-transform: uppercase;
}
.ssb__option {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 42px;
    padding: 8px var(--ssb-pad-x);
    color: var(--ssb-text-soft);
    font-size: 15px;
    cursor: pointer;
    user-select: none;
}
.ssb__option.is-active { background: var(--ssb-active-bg); }
.ssb__option--history { padding-right: 12px; }
.ssb__option-icon {
    flex: none;
    display: inline-flex;
    color: var(--ssb-muted);
}
.ssb__option-icon svg { width: 18px; height: 18px; }
.ssb__text {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
}
/* Keywords are stored in lower case; capitalise only for display. */
.ssb__text::first-letter { text-transform: uppercase; }
.ssb__text--plain::first-letter { text-transform: none; }
.ssb__hit { color: var(--ssb-text-strong); font-weight: 500; }
.ssb__remove { margin: -6px 0; opacity: .75; }
.ssb__remove:hover { opacity: 1; }

.ssb__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 2px var(--ssb-pad-x) 8px;
}
.ssb__chip {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 7px 14px;
    border: 1px solid var(--ssb-chip-line);
    border-radius: 999px;
    background: var(--ssb-surface);
    color: var(--ssb-text);
    font-size: 14px;
    line-height: 1.3;
    cursor: pointer;
    user-select: none;
    transition: border-color .15s ease, background-color .15s ease;
}
.ssb__chip.is-active { border-color: var(--ssb-accent); background: var(--ssb-active-bg); }

.ssb__note {
    padding: 14px var(--ssb-pad-x) 6px;
    color: var(--ssb-text-soft);
    font-size: 15px;
    line-height: 1.5;
}
.ssb__note a { color: var(--ssb-accent); }
.ssb__divider { height: 1px; margin: 8px var(--ssb-pad-x) 4px; background: var(--ssb-line); }
.ssb__option--submit { color: var(--ssb-accent); }
.ssb__option--submit .ssb__option-icon { color: var(--ssb-accent); }
.ssb__option--submit strong { font-weight: 500; }
.ssb__kbd {
    flex: none;
    padding: 2px 8px;
    border: 1px solid var(--ssb-chip-line);
    border-radius: 6px;
    background: transparent;
    box-shadow: none;
    color: var(--ssb-muted);
    font-family: inherit;
    font-size: 12px;
}

.ssb__footer { display: none; }

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

/* Phones and small tablets: searching takes the whole screen. */
.ssb--fullscreen .ssb__card {
    position: fixed;
    inset: 0;
    z-index: var(--ssb-z-fullscreen);
    display: flex;
    flex-direction: column;
    border-radius: 0;
    background: var(--ssb-surface);
    box-shadow: none;
}
.ssb--fullscreen .ssb__field {
    flex: none;
    height: auto;
    padding: 12px 12px 12px 4px;
    border-bottom: 1px solid var(--ssb-line);
}
.ssb--fullscreen .ssb__back { width: 44px; height: 44px; color: var(--ssb-text); }
.ssb--fullscreen .ssb__back svg { width: 22px; height: 22px; }
.ssb--fullscreen .ssb__input {
    height: 48px;
    padding: 0 44px 0 18px;
    border-radius: 24px;
    background: var(--ssb-field-bg);
    font-size: 16px;
}
.ssb--fullscreen .ssb__clear { margin-left: -44px; margin-right: 4px; }
.ssb--fullscreen .ssb__panel {
    flex: 1 1 0;
    min-height: 0;
    max-height: none;
    padding-bottom: 8px;
}
.ssb--fullscreen .ssb__panel::before { display: none; }
.ssb--fullscreen .ssb__heading { padding-left: 20px; padding-right: 20px; padding-top: 16px; }
.ssb--fullscreen .ssb__option { min-height: 48px; padding-left: 20px; padding-right: 20px; font-size: 16px; }
.ssb--fullscreen .ssb__option--history { padding-right: 8px; }
.ssb--fullscreen .ssb__chips { padding-left: 20px; padding-right: 20px; }
.ssb--fullscreen .ssb__chip { min-height: 40px; font-size: 15px; }
.ssb--fullscreen .ssb__kbd { display: none; }
/* The footer button already offers "search this". */
.ssb--fullscreen .ssb__divider,
.ssb--fullscreen .ssb__option--submit { display: none; }
.ssb--fullscreen .ssb__footer {
    display: block;
    flex: none;
    padding: 12px 16px calc(8px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--ssb-line);
    background: var(--ssb-surface);
}
.ssb__footer-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: 52px;
    margin: 0;
    padding: 0 20px;
    border: 0;
    border-radius: 999px;
    background: var(--ssb-accent);
    color: #fff;
    font: inherit;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.ssb__footer-btn .ssb__option-icon { color: inherit; }
.ssb__footer-close {
    display: block;
    min-height: 44px;
    margin: 4px auto 0;
    padding: 8px 16px;
    border: 0;
    background: transparent;
    color: var(--ssb-text-soft);
    font: inherit;
    font-size: 14px;
    cursor: pointer;
}
.ssb__footer-close:hover { color: var(--ssb-accent); text-decoration: underline; }
html.ssb-scroll-lock, html.ssb-scroll-lock body { overflow: hidden; }

/* On-screen keyboard up (the sheet is sized to what stays visible): the keyboard's
   own search key submits, so the footer gives its room to the suggestions. */
.ssb--keyboard .ssb__footer { display: none; }
.ssb--keyboard .ssb__filters { max-height: 30%; }

/* Filters in use: suggestions are hidden, so there is one scrolling area, not two. */
.ssb--filtering .ssb__filters {
    flex: 1 1 0;
    max-height: none;
    border-top: 0;
}

/* Page filters are always available at the bottom of the full-screen sheet. */
.ssb__filters {
    flex: 0 1 auto;
    min-height: 0;
    max-height: 48vh;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 14px 20px 12px;
    border-top: 1px solid var(--ssb-line);
}
.ssb-filters__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 24px;
    margin-bottom: 10px;
}
.ssb-filters__title {
    color: var(--ssb-muted);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: .06em;
    text-transform: uppercase;
}
.ssb-filters__reset {
    padding: 2px 0;
    border: 0;
    background: none;
    color: var(--ssb-accent);
    font: inherit;
    font-size: 14px;
    cursor: pointer;
}
.ssb-filters__toggles {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.ssb-filters__toggle {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 40px;
    padding: 0 11px 0 14px;
    border: 1px solid var(--ssb-chip-line);
    border-radius: 999px;
    background: var(--ssb-surface);
    color: var(--ssb-text);
    font: inherit;
    font-size: 15px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: border-color .15s ease, background-color .15s ease;
}
.ssb-filters__toggle .bi { font-size: 12px; line-height: 1; color: var(--ssb-muted); transition: transform .2s ease; }
.ssb-filters__toggle.is-set { border-color: var(--ssb-accent); background: var(--ssb-active-bg); color: var(--ssb-text-strong); }
.ssb-filters__toggle.is-open { border-color: var(--ssb-accent); box-shadow: var(--ssb-ring); }
.ssb-filters__toggle.is-open .bi { transform: rotate(180deg); }
.ssb-filters__badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--ssb-accent, #4063c9);  /* also used outside .ssb */
    color: #fff;
    font-size: 12px;
    font-weight: 500;
    line-height: 1;
}
.ssb-filters__options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 12px;
}
.ssb-filters__chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 38px;
    padding: 6px 14px;
    border: 1px solid var(--ssb-chip-line);
    border-radius: 999px;
    background: var(--ssb-surface);
    color: var(--ssb-text);
    font: inherit;
    font-size: 14px;
    line-height: 1.3;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.ssb-filters__chip .bi { font-size: 15px; line-height: 1; }
.ssb-filters__chip.is-selected { border-color: var(--ssb-accent); background: var(--ssb-accent); color: #fff; }
.ssb-filters__years {
    display: flex;
    gap: 12px;
    padding-top: 12px;
}
.ssb-filters__years label {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
    color: var(--ssb-muted);
    font-size: 13px;
}
.ssb-filters__years select {
    height: 44px;
    padding: 0 12px;
    border: 1px solid var(--ssb-chip-line);
    border-radius: 12px;
    background-color: var(--ssb-surface);
    color: var(--ssb-text);
    font: inherit;
    font-size: 16px;
}

/* Results page (phones): opens the search sheet on its filters. */
.ssb-filters-open {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 40px;
    padding: 0 14px;
    border: 1px solid #d9dde6;
    border-radius: 999px;
    background: #fff;
    color: #353a40;
    font: inherit;
    font-size: 15px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.ssb-filters-open .bi { font-size: 16px; line-height: 1; color: #4063c9; }
.ssb-filters-open:focus-visible { outline: 2px solid #4063c9; outline-offset: 2px; }

/* Active filters on the results page (phones), removable one by one. */
.ssb-active-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}
.ssb-active-filters__label { color: #6b7280; font-size: 14px; margin-right: 2px; }
.ssb-active-filters__chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    min-height: 34px;
    padding: 4px 8px 4px 12px;
    border: 1px solid #4063c9;
    border-radius: 999px;
    background: #eef2fb;
    color: #1f2430;
    font: inherit;
    font-size: 14px;
    line-height: 1.2;
    cursor: pointer;
}
.ssb-active-filters__chip .bi { font-size: 18px; line-height: 1; color: #4063c9; }
.ssb-active-filters__reset {
    border: 0;
    background: none;
    padding: 4px 2px;
    color: #4063c9;
    font: inherit;
    font-size: 14px;
    cursor: pointer;
}

/* Pages that filter their own lists (live mode): highlight and result count. */
.ssb-hit {
    padding: 0 1px;
    border-radius: 3px;
    background: #e6ecfa;
    color: inherit;
    font-weight: 500;
    -webkit-box-decoration-break: clone;
    box-decoration-break: clone;
}
.ssb-status {
    margin: 0;
    color: #4b5160;
    font-size: 15px;
}
.ssb-status strong { font-weight: 500; color: #353a40; }

@media (prefers-reduced-motion: reduce) {
    .ssb__card, .ssb__icon-btn, .ssb__submit, .ssb__chip,
    .ssb-filters__toggle, .ssb-filters__toggle .bi { transition: none; }
}
