/* ═══════════════════════════════════════════════════════════════════════════
   قالب آریا – search-pop.css
   The site search pop-up: one pill (search icon + field) and, under it, a rounded
   card of live results. Near the top of the screen on phones, so the keyboard
   never covers it. Overrides the theme's older capsule styles in main.css.
   ═══════════════════════════════════════════════════════════════════════════ */

html body .search-capsule-container.arya-sp {
    position: fixed;
    top: clamp(16px, 14vh, 140px) !important;
    left: 50%;
    z-index: 9999;
    width: min(640px, calc(100% - 24px)) !important;
    max-width: none !important;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0;
    overflow: visible;
    border: 0 !important;
    border-radius: 0;
    background: transparent !important;
    box-shadow: none;
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, -14px) !important;
    /* closing: fade out, then hide */
    transition: opacity .25s cubic-bezier(.4, 0, .2, 1), transform .3s cubic-bezier(.34, 1.56, .64, 1), visibility 0s linear .25s;
}
/* opening: visible at once (so the field can take focus and the phone keyboard opens), then fade in */
html body .search-capsule-container.arya-sp.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0) !important;
    transition: opacity .25s cubic-bezier(.4, 0, .2, 1), transform .3s cubic-bezier(.34, 1.56, .64, 1), visibility 0s;
}
body.arya-sp-open { overflow: hidden; }

/* the pill */
.arya-sp__bar {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 62px;
    margin: 0;
    padding: 0 8px;
    border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border-color));
    border-radius: 999px;
    background: var(--bg-card);
    box-shadow: 0 18px 50px rgba(0, 0, 0, .28), 0 0 0 6px color-mix(in srgb, var(--accent) 12%, transparent);
    transition: box-shadow .2s, border-color .2s;
}
.arya-sp__bar:focus-within { border-color: var(--accent); box-shadow: 0 18px 50px rgba(0, 0, 0, .28), 0 0 0 6px color-mix(in srgb, var(--accent) 20%, transparent); }
.arya-sp__icon {
    width: 46px;
    height: 46px;
    flex: none;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 1.05rem;
    box-shadow: 0 6px 16px color-mix(in srgb, var(--accent) 40%, transparent);
}
.arya-sp__input {
    flex: 1;
    min-width: 0;
    height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--text-main);
    font: inherit;
    font-size: 1.05rem;
    outline: none;
    box-shadow: none;
    -webkit-appearance: none;
    appearance: none;
}
.arya-sp__input::placeholder { color: var(--text-muted); opacity: 1; }
.arya-sp__input::-webkit-search-cancel-button,
.arya-sp__input::-webkit-search-decoration { -webkit-appearance: none; appearance: none; display: none; }
/* a small ring while results are on their way */
.arya-sp__spin {
    width: 18px;
    height: 18px;
    flex: none;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    opacity: 0;
    transition: opacity .15s;
}
.arya-sp.is-loading .arya-sp__spin { opacity: 1; animation: arya-sp-spin .7s linear infinite; }
/* close: a round button at the far end of the pill, opposite the search icon */
.arya-sp__close {
    width: 42px;
    height: 42px;
    flex: none;
    display: grid;
    place-items: center;
    margin: 0;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    background: var(--bg-element);
    color: var(--text-muted);
    font-size: .95rem;
    cursor: pointer;
    transition: background-color .2s, color .2s, border-color .2s, transform .25s cubic-bezier(.34, 1.56, .64, 1);
}
.arya-sp__close:hover { border-color: transparent; background: var(--accent-red, #e74c3c); color: #fff; transform: rotate(90deg); }
.arya-sp__close:active { transform: scale(.92); }
.arya-sp__close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@keyframes arya-sp-spin { to { transform: rotate(360deg); } }

/* the results card */
.arya-sp__panel {
    max-height: min(62vh, 540px);
    padding: 8px;
    overflow-y: auto;
    overscroll-behavior: contain;
    border: 1px solid var(--border-color);
    border-radius: 26px;
    background: var(--bg-card);
    box-shadow: 0 18px 50px rgba(0, 0, 0, .25);
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
    animation: arya-sp-in .22s cubic-bezier(.4, 0, .2, 1);
}
.arya-sp__panel[hidden] { display: none; }
@keyframes arya-sp-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.arya-sp__item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    border-radius: 18px;
    color: var(--text-main);
    text-decoration: none;
    transition: background-color .15s;
}
.arya-sp__item:hover, .arya-sp__item.is-active { background: var(--bg-element); color: var(--text-main); }
.arya-sp__item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.arya-sp__thumb { width: 56px; height: 56px; flex: none; border-radius: 14px; object-fit: cover; background: var(--bg-element); }
.arya-sp__thumb--icon {
    display: grid;
    place-items: center;
    border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    color: var(--accent);
    font-size: 1.15rem;
}
.arya-sp__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.arya-sp__title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: .92rem;
    font-weight: 700;
    line-height: 1.65;
    text-wrap: pretty;
}
.arya-sp__title mark { padding: 0 2px; border-radius: 4px; background: color-mix(in srgb, var(--accent) 22%, transparent); color: inherit; }
.arya-sp__meta { overflow: hidden; color: var(--text-muted); font-size: .76rem; line-height: 1.6; text-overflow: ellipsis; white-space: nowrap; }
.arya-sp__meta i { margin-inline-end: 4px; font-size: .7rem; opacity: .8; }
.arya-sp__all {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 46px;
    margin: 6px 4px 2px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent) 10%, transparent);
    color: var(--accent);
    font-size: .86rem;
    font-weight: 700;
    text-decoration: none;
    transition: background-color .15s, color .15s;
}
.arya-sp__all:hover, .arya-sp__all.is-active { background: var(--accent); color: #fff; }
.arya-sp__empty { margin: 0; padding: 22px 16px; color: var(--text-muted); font-size: .88rem; text-align: center; }
.arya-sp__empty i { display: block; margin-bottom: 8px; font-size: 1.4rem; opacity: .5; }

/* phones: near the top (keyboard below), a little more compact */
@media (max-width: 600px) {
    html body .search-capsule-container.arya-sp { top: calc(env(safe-area-inset-top, 0px) + 12px) !important; width: calc(100% - 20px) !important; }
    body.admin-bar .search-capsule-container.arya-sp { top: 58px !important; }
    .arya-sp__bar { height: 56px; gap: 8px; padding: 0 6px; }
    .arya-sp__icon { width: 44px; height: 44px; font-size: 1rem; }
    .arya-sp__close { width: 40px; height: 40px; }
    .arya-sp__input { font-size: 16px; }          /* 16px keeps iOS from zooming in */
    .arya-sp__panel { max-height: calc(100dvh - 140px); border-radius: 22px; padding: 6px; }
    .arya-sp__thumb { width: 52px; height: 52px; border-radius: 12px; }
    .arya-sp__title { font-size: .88rem; }
}
@media (min-width: 601px) and (max-width: 782px) {
    body.admin-bar .search-capsule-container.arya-sp { top: 70px !important; }
}

@media (prefers-reduced-motion: reduce) {
    html body .search-capsule-container.arya-sp, .arya-sp__panel { transition: none; animation: none; }
}
