/* ============================================================
 * SITEWIDE SEARCH OVERLAY
 * Markup: utils/footer.php (appended at page end so it is a direct
 *         child of <body> — a fixed overlay nested inside a
 *         transformed ancestor would be trapped by its stacking
 *         context. See feedback_stacking_context_modals.)
 * Trigger: #aat-search-open (desktop nav + mobile bar) in utils/header.php
 * Index:   assets/search.json, built by scripts/build_search_index.php
 *
 * z-index note: the 99996-100001 band is already taken (flatpickr,
 * vehicle lightbox, compare, floating widget). Search is a takeover
 * modal, so it sits one above the ceiling at 100002.
 * ============================================================ */

.aat-search-ov {
    position: fixed;
    inset: 0;
    z-index: 100002;
    display: none;
    background: rgba(3, 3, 3, 0.97);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
}

.aat-search-ov.is-open {
    display: block;
    animation: aatSearchIn 220ms ease-out;
}

@keyframes aatSearchIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

/* ---- Shell ---- */
.aat-search-shell {
    max-width: 760px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 0 1.25rem;
}

/* ---- Top row: input + close ---- */
.aat-search-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.5rem 0 1rem;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(212, 175, 55, 0.28);
}

.aat-search-bar .aat-search-glyph {
    flex-shrink: 0;
    opacity: 0.75;
    display: flex;
    align-items: center;
}

.aat-search-input {
    flex: 1 1 auto;
    min-width: 0;
    background: transparent;
    border: 0;
    outline: 0;
    /* type="search" carries browser-drawn chrome; strip it so only our styling shows. */
    -webkit-appearance: none;
    appearance: none;
    color: #fff;
    font-family: var(--font-heading), serif;
    font-size: 1.75rem;
    line-height: 1.2;
    padding: 0.25rem 0;
}

.aat-search-input::placeholder {
    color: rgba(255, 255, 255, 0.32);
}

/* Kill the browser's native clear button for <input type="search">.
   It only appears once there is text, is drawn by the browser in its own
   accent colour (blue), ignores our dark/gold system entirely, and sat right
   next to our gold close button — two X's, one of them off-brand.
   Chrome / Safari / Edge are all Chromium or WebKit, so ::-webkit-* covers
   every browser we support. (::-ms-clear is deliberately NOT here: Chromium
   drops it as an unknown pseudo-element — verified in the CSSOM — so it would
   only ever have applied to legacy Edge / IE11, both EOL since 2021.) */
.aat-search-input::-webkit-search-cancel-button,
.aat-search-input::-webkit-search-decoration,
.aat-search-input::-webkit-search-results-button,
.aat-search-input::-webkit-search-results-decoration {
    -webkit-appearance: none;
    appearance: none;
    display: none;
}

.aat-search-close {
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 9999px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(212, 175, 55, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 200ms ease, border-color 200ms ease;
    cursor: pointer;
}

.aat-search-close:hover {
    background: rgba(212, 175, 55, 0.12);
    border-color: rgba(212, 175, 55, 0.6);
}

/* ---- Results scroller ---- */
.aat-search-results {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 1rem 0 3rem;
}

.aat-search-group {
    margin-bottom: 1.5rem;
}

.aat-search-group-label {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #D4AF37;
    padding: 0 0.25rem 0.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    margin-bottom: 0.5rem;
}

/* ---- A single hit ---- */
.aat-search-hit {
    display: block;
    padding: 0.7rem 0.75rem;
    border-radius: 0.5rem;
    border: 1px solid transparent;
    text-decoration: none;
    transition: background 150ms ease, border-color 150ms ease;
    cursor: pointer;
}

.aat-search-hit:hover,
.aat-search-hit.is-active {
    background: rgba(212, 175, 55, 0.08);
    border-color: rgba(212, 175, 55, 0.35);
}

.aat-search-hit-title {
    color: #fff;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.35;
    margin-bottom: 0.15rem;
}

.aat-search-hit-body {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.8rem;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* The matched term, highlighted in the hit. Gold, never a background
   block — a full highlight block fights the dark/gold system. */
.aat-search-hit mark {
    background: transparent;
    color: #D4AF37;
    font-weight: 700;
}

/* FAQ hits carry the source page as a trailing crumb. */
.aat-search-hit-crumb {
    display: inline-block;
    margin-top: 0.3rem;
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(212, 175, 55, 0.65);
}

/* ---- Curated answer card ----
   Sits above the page results. Deliberately distinct from a .aat-search-hit:
   this is an answer, not a link to go read one. */
.aat-search-answer {
    border: 1px solid rgba(212, 175, 55, 0.42);
    border-radius: 0.75rem;
    background: linear-gradient(180deg, rgba(212, 175, 55, 0.07), rgba(212, 175, 55, 0.02));
    padding: 1.1rem 1.15rem 1.25rem;
    /* Breathing room + a hairline rule below, so the answer reads as its own
       thing rather than as the first search result. */
    margin-bottom: 2.5rem;
    padding-bottom: 1.35rem;
    position: relative;
}

.aat-search-answer::after {
    content: "";
    position: absolute;
    left: 12%;
    right: 12%;
    bottom: -1.25rem;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
}

.aat-search-answer-label {
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.22em;
    text-transform: uppercase;
    color: #D4AF37;
    margin-bottom: 0.4rem;
}

.aat-search-answer-title {
    font-family: var(--font-heading), serif;
    font-size: 1.35rem;
    line-height: 1.2;
    color: #fff;
    margin-bottom: 0.4rem;
}

.aat-search-answer-body {
    color: rgba(255, 255, 255, 0.74);
    font-size: 0.875rem;
    line-height: 1.6;
    margin-bottom: 0.9rem;
}

.aat-search-answer-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
}

/* ---- Empty / no-results states ---- */
.aat-search-msg {
    text-align: center;
    padding: 2.5rem 1rem;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.9rem;
}

/* No-results routes to the concierge — never a cold dead end.
   Uses the sitewide .concierge-bg contract (assets/css/concierge.css). */
.aat-search-empty {
    border-radius: 0.75rem;
    border: 1px solid rgba(212, 175, 55, 0.3);
    overflow: hidden;
    padding: 2.25rem 1.5rem;
    text-align: center;
}

.aat-search-empty h3 {
    font-family: var(--font-heading), serif;
    font-size: 1.5rem;
    color: #fff;
    margin-bottom: 0.5rem;
}

.aat-search-empty p {
    color: rgba(255, 255, 255, 0.62);
    font-size: 0.875rem;
    max-width: 42ch;
    margin: 0 auto 1.25rem;
    line-height: 1.6;
}

.aat-search-empty-actions {
    display: flex;
    gap: 0.6rem;
    justify-content: center;
    flex-wrap: wrap;
}

.aat-search-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.6rem 1.4rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    text-decoration: none;
    transition: all 250ms ease;
}

.aat-search-cta--gold {
    background: #D4AF37;
    color: #000;
    border: 1px solid rgba(243, 217, 138, 0.8);
}

.aat-search-cta--gold:hover {
    background: #e7c861;
}

.aat-search-cta--ghost {
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #fff;
}

.aat-search-cta--ghost:hover {
    border-color: #D4AF37;
    background: rgba(255, 255, 255, 0.05);
}

/* ---- Keyboard hint ---- */
.aat-search-hint {
    flex-shrink: 0;
    display: flex;
    gap: 1rem;
    justify-content: center;
    padding: 0.75rem 0 1.25rem;
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.28);
    border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.aat-search-hint kbd {
    font-family: inherit;
    color: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 0.2rem;
    padding: 0.05rem 0.3rem;
    margin-right: 0.25rem;
}

/* ---- Trigger button (header) ---- */
.aat-search-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 9999px;
    border: 1px solid transparent;
    background: transparent;
    color: #fff;
    cursor: pointer;
    transition: background 200ms ease, border-color 200ms ease;
}

.aat-search-trigger:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(212, 175, 55, 0.4);
}

/* ---- Mobile ---- */
@media (max-width: 640px) {
    .aat-search-shell { padding: 0 1rem; }
    .aat-search-input { font-size: 1.35rem; }
    .aat-search-bar   { padding: 1rem 0 0.75rem; }
    /* The hint row is desktop affordance; keyboards do not apply on touch. */
    .aat-search-hint  { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .aat-search-ov.is-open { animation: none; }
    .aat-search-hit,
    .aat-search-close,
    .aat-search-trigger { transition: none; }
}
