/* ============================================================
   ATLAS SEARCH
   Shared global search launcher for Atlas OS.

   Structure and interaction live here.
   World and appearance values come from atlas-modal-theme.css.
   ============================================================ */

.atlas-search-overlay {
    position: fixed;
    inset: 0;
    z-index: 580;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 4rem 1rem 2rem;
    overflow: hidden;
    overscroll-behavior: contain;
    background: var(--atlas-modal-overlay-bg);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.atlas-search-overlay.open {
    display: flex;
    animation: atlasSearchFadeIn 0.15s ease;
}

.atlas-search-panel {
    width: 100%;
    max-width: var(--atlas-overlay-width);
    overflow: hidden;
    overscroll-behavior: contain;
    border: 1px solid var(--atlas-modal-border);
    border-radius: var(--atlas-modal-radius-lg);
    background: var(--atlas-modal-surface);
    color: var(--atlas-modal-text);
    box-shadow: var(--atlas-modal-shadow);
    font-family: var(--atlas-modal-font-body);
    animation: atlasSearchSlideUp 0.2s cubic-bezier(0.34, 1.25, 0.64, 1);
}

.atlas-search-input-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.9rem 1.1rem;
    border-bottom: 1px solid var(--atlas-modal-border);
    background: var(--atlas-modal-surface-low);
}

.atlas-search-input-row svg {
    flex-shrink: 0;
    color: var(--atlas-modal-muted);
}

.atlas-search-input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    color: var(--atlas-modal-heading);
    caret-color: var(--atlas-modal-accent);
    font-family: var(--atlas-modal-font-body);
    font-size: 0.95rem;
}

.atlas-search-input::placeholder {
    color: var(--atlas-modal-muted);
}

/* The panel hugs the resting result set. Only longer typed-result
   lists scroll inside this bounded region. */
.atlas-search-results {
    max-height: 420px;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0.3rem 0 0.4rem;
    background: var(--atlas-modal-surface);
    scrollbar-width: thin;
    scrollbar-color: var(--atlas-modal-scrollbar) transparent;
}

.atlas-search-results::-webkit-scrollbar {
    width: 10px;
}

.atlas-search-results::-webkit-scrollbar-track {
    background: transparent;
}

.atlas-search-results::-webkit-scrollbar-thumb {
    border: 3px solid transparent;
    border-radius: 999px;
    background: var(--atlas-modal-scrollbar);
    background-clip: padding-box;
}

.atlas-search-results::-webkit-scrollbar-thumb:hover {
    background: var(--atlas-modal-scrollbar-hover);
    background-clip: padding-box;
}

.atlas-search-group-label {
    padding: 0.55rem 1.1rem 0.28rem;
    color: var(--atlas-modal-muted);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

.atlas-search-result {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.64rem 1.1rem;
    cursor: pointer;
    transition: none;
}

/* Search-list feedback stays immediate and independent of host-page
   appearance-transition systems. */
.atlas-search-result::before,
.atlas-search-result::after,
.atlas-search-result-icon,
.atlas-search-result-icon svg,
.atlas-search-result-title,
.atlas-search-result-sub {
    transition: none;
}

/* Hover is passive. Focus carries the accent rail because Enter
   will launch the focused row. */
.atlas-search-result:hover {
    background: var(--atlas-modal-accent-bg);
}

.atlas-search-result.focused {
    background: var(--atlas-modal-accent-bg-strong);
    box-shadow: inset 3px 0 0 var(--atlas-modal-accent);
}

.atlas-search-result.is-disabled {
    cursor: default;
    opacity: 0.62;
}

.atlas-search-result.is-disabled:hover,
.atlas-search-result.is-disabled.focused {
    background: transparent;
    box-shadow: none;
}

.atlas-search-result-icon {
    display: flex;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--atlas-modal-neutral-icon-border);
    border-radius: 9px;
    background: var(--atlas-modal-neutral-icon-bg);
    color: var(--atlas-modal-neutral-icon-text);
}

.atlas-search-result-icon svg {
    width: 16px;
    height: 16px;
}

/* Atlas, Compass, and Arcade destinations stay visually neutral.
   Content icons retain the identity of their owning world. */
.atlas-search-result-icon-home,
.atlas-search-result-icon-world {
    border-color: var(--atlas-modal-neutral-icon-border);
    background: var(--atlas-modal-neutral-icon-bg);
    color: var(--atlas-modal-neutral-icon-text);
}

.atlas-search-result-icon-subject {
    border-color: var(--atlas-modal-subject-icon-border);
    background: var(--atlas-modal-subject-icon-bg);
    color: var(--atlas-modal-subject-icon-text);
}

.atlas-search-result-icon-game {
    border-color: var(--atlas-modal-game-icon-border);
    background: var(--atlas-modal-game-icon-bg);
    color: var(--atlas-modal-game-icon-text);
}

.atlas-search-result-body {
    flex: 1;
    min-width: 0;
}

.atlas-search-result-title {
    overflow: hidden;
    color: var(--atlas-modal-heading);
    font-size: 0.88rem;
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.atlas-search-result-sub {
    overflow: hidden;
    color: var(--atlas-modal-muted);
    font-size: 0.75rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.atlas-search-empty {
    padding: 1.5rem 1.1rem;
    color: var(--atlas-modal-muted);
    font-size: 0.85rem;
    line-height: 1.6;
    text-align: center;
}

[data-atlas-search] svg {
    pointer-events: none;
}

/* ============================================================
   RESPONSIVE LAYOUT
   ============================================================ */

@media (max-width: 680px) {
    .atlas-search-overlay {
        padding: 2rem 0.75rem 1rem;
    }
}

/* ============================================================
   MOTION
   ============================================================ */

@keyframes atlasSearchFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes atlasSearchSlideUp {
    from {
        opacity: 0;
        transform: translateY(14px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .atlas-search-overlay.open,
    .atlas-search-panel {
        animation: none;
    }
}