/* ==========================================================================
   Recherche prédictive du header (js/search-suggest.js, api/searchsuggest.php)
   Panneau sous le champ #chSearchInput - s'appuie sur les variables de css/chavigny.css
   ========================================================================== */

.ss-panel {
    position: absolute;
    z-index: 1200;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    overflow: hidden;
    border: 1px solid var(--ch-border);
    border-radius: var(--ch-radius-lg, 14px);
    background: var(--ch-white);
    box-shadow: 0 18px 48px rgba(42, 43, 46, .18);
    text-align: left;
    animation: ss-in .16s var(--ch-ease);
}

.ss-panel[hidden] {
    display: none;
}

@keyframes ss-in {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: none; }
}

.ss-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    border: 0;
    white-space: nowrap;
}

/* En-tête */
.ss-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px 8px;
}

.ss-title {
    color: var(--ch-grey);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .07em;
    text-transform: uppercase;
}

.ss-count {
    color: var(--ch-grey-dark);
    font-size: .8rem;
}

/* Liste */
.ss-list {
    margin: 0;
    padding: 0 8px 8px;
    list-style: none;
}

.ss-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px;
    border-radius: var(--ch-radius);
    color: var(--ch-text);
    text-decoration: none;
    transition: background-color .15s var(--ch-ease);
}

.ss-item:hover,
.ss-item:focus-visible {
    background: var(--ch-grey-light);
    color: var(--ch-text);
    text-decoration: none;
    outline: none;
}

.ss-item:focus-visible {
    box-shadow: inset 0 0 0 2px var(--ch-red);
}

.ss-img {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    padding: 4px;
    border: 1px solid var(--ch-border);
    border-radius: var(--ch-radius-sm, 6px);
    background: var(--ch-white);
}

.ss-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Image introuvable : pictogramme neutre */
.ss-img i {
    display: none;
    color: var(--ch-border);
    font-size: 1.4rem;
}

.ss-img.is-empty {
    background: var(--ch-grey-light);
}

.ss-img.is-empty i {
    display: block;
}

.ss-text {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.ss-name {
    display: -webkit-box;
    overflow: hidden;
    font-size: .92rem;
    font-weight: 600;
    line-height: 1.35;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow-wrap: anywhere;
}

.ss-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 0;
    color: var(--ch-grey);
    font-size: .78rem;
}

.ss-meta strong {
    color: var(--ch-grey-dark);
    font-weight: 600;
}

.ss-dot {
    width: 3px;
    height: 3px;
    margin: 0 8px;
    border-radius: 50%;
    background: var(--ch-grey);
}

.ss-panel mark {
    padding: 0;
    background: none;
    color: var(--ch-red);
    font-weight: 700;
}

.ss-arrow {
    flex-shrink: 0;
    color: var(--ch-border);
    font-size: .85rem;
    transition: color .15s var(--ch-ease), transform .15s var(--ch-ease);
}

.ss-item:hover .ss-arrow,
.ss-item:focus-visible .ss-arrow {
    color: var(--ch-red);
    transform: translateX(2px);
}

/* « Voir les résultats » */
.ss-more {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 18px;
    border-top: 1px solid var(--ch-border);
    background: var(--ch-grey-light);
    color: var(--ch-text);
    font-size: .9rem;
    text-decoration: none;
    transition: background-color .15s var(--ch-ease), color .15s var(--ch-ease);
}

.ss-more strong {
    font-weight: 700;
}

.ss-more i {
    color: var(--ch-red);
    transition: transform .15s var(--ch-ease), color .15s var(--ch-ease);
}

.ss-more:hover,
.ss-more:focus-visible {
    background: var(--ch-red);
    color: var(--ch-white);
    text-decoration: none;
    outline: none;
}

.ss-more:hover i,
.ss-more:focus-visible i {
    color: var(--ch-white);
    transform: translateX(3px);
}

/* Aucun résultat */
.ss-empty {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 18px;
}

.ss-empty-icon {
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--ch-grey-light);
    color: var(--ch-grey-dark);
}

.ss-empty p {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
    font-size: .9rem;
    line-height: 1.45;
    overflow-wrap: anywhere;
}

.ss-empty span {
    color: var(--ch-grey-dark);
    font-size: .84rem;
}

/* Chargement */
.ss-skeleton {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 10px;
}

.ss-skel-img,
.ss-skel-lines span {
    border-radius: 6px;
    background: linear-gradient(90deg, var(--ch-grey-light) 25%, #f7f7f7 50%, var(--ch-grey-light) 75%);
    background-size: 200% 100%;
    animation: ss-shimmer 1.2s linear infinite;
}

.ss-skel-img {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
}

.ss-skel-lines {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 8px;
}

.ss-skel-lines span {
    height: 12px;
}

.ss-skel-lines span:first-child {
    width: 85%;
}

.ss-skel-lines span:last-child {
    width: 45%;
}

@keyframes ss-shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

/* Tablette et mobile : panneau sur toute la largeur du champ, défilable, cibles tactiles plus grandes */
@media (max-width: 991.98px) {
    .ss-panel {
        max-height: calc(100vh - 150px);
        max-height: calc(100dvh - 150px);
        overflow-y: auto;
        overscroll-behavior: contain;
    }

    .ss-item {
        min-height: 64px;
    }
}

@media (max-width: 575.98px) {
    .ss-panel {
        top: calc(100% + 6px);
        border-radius: var(--ch-radius);
    }

    .ss-head {
        padding: 10px 14px 6px;
    }

    .ss-list {
        padding: 0 4px 4px;
    }

    .ss-item {
        gap: 12px;
        padding: 10px;
    }

    .ss-img {
        width: 48px;
        height: 48px;
    }

    .ss-arrow {
        display: none;
    }

    .ss-more {
        padding: 14px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ss-panel,
    .ss-skel-img,
    .ss-skel-lines span {
        animation: none;
    }
}
