/**!
 * @file GlobalSearch.css
 * @desc Site-wide spotlight search component — magnifying glass button in
 *       the navbar that opens an overlay dropdown anchored beneath the icon.
 *       Streams live results across lessons / series / themes / vocab /
 *       quizzes, grouped by type with click-to-navigate rows.
 */
/************************************************************************************************************************************/

/* ======== Magnifying-glass trigger in the nav ======== */

.gs-trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.92);
    font-size: 0.98rem;
    cursor: pointer;
    border-radius: 50%;
    transition: background 0.12s ease, color 0.12s ease;
    padding: 0;
}

.gs-trigger:hover,
.gs-trigger.is-open {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}

/* ======== Backdrop + dropdown overlay ======== */

.gs-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(20, 50, 30, 0.18);
    z-index: 9998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.gs-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}

.gs-panel {
    position: fixed;
    top: 0;
    left: 50%;
    transform: translate(-50%, -12px);
    width: min(560px, calc(100vw - 24px));
    max-height: calc(100vh - 96px);
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 24px 60px rgba(20, 50, 30, 0.28),
                0 2px 8px rgba(20, 50, 30, 0.12);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, transform 0.18s ease, visibility 0s linear 0.18s;
    color: #14211a;
}

.gs-panel.is-open {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
    transition: opacity 0.15s ease, transform 0.18s ease;
}

/* Search input row at the top of the panel */

.gs-input-row {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 14px 16px;
    border-bottom: 1px solid #e0e8e3;
}

.gs-input-row__icon {
    flex-shrink: 0;
    color: #0e6630;
    font-size: 1.05rem;
    padding-right: 12px;
}

.gs-input-row__input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1.02rem;
    background: transparent;
    color: #14211a;
    font-family: inherit;
    min-width: 0;
}

.gs-input-row__input::placeholder {
    color: #6a7770;
}

.gs-input-row__close {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: #6a7770;
    cursor: pointer;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.12s ease, color 0.12s ease;
}

.gs-input-row__close:hover {
    background: rgba(14, 102, 48, 0.08);
    color: #084a22;
}

/* Results scrollable area */

.gs-results {
    overflow-y: auto;
    flex: 1;
    min-height: 60px;
    padding: 4px 0 8px 0;
}

.gs-results__hint {
    text-align: center;
    color: #6a7770;
    font-size: 0.88rem;
    padding: 22px 16px;
    line-height: 1.5;
}

.gs-results__loading {
    text-align: center;
    color: #6a7770;
    font-size: 0.85rem;
    padding: 18px 16px;
}

.gs-results__loading i {
    color: #0e6630;
    margin-right: 6px;
    animation: gs-spin 0.8s linear infinite;
}

@keyframes gs-spin {
    to { transform: rotate(360deg); }
}

/* ======== Result groups ======== */

.gs-group {
    padding: 6px 0;
}

.gs-group__head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px 4px 16px;
    color: #4a5b51;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.gs-group__count {
    color: #4a5b51;
    background: #e8f3ec;
    font-weight: 700;
    font-size: 0.7rem;
    padding: 1px 8px;
    border-radius: 999px;
}

.gs-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 8px 16px;
    color: #14211a;
    text-decoration: none;
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: background 0.1s ease, border-color 0.1s ease;
}

.gs-item:hover,
.gs-item.is-focus {
    background: #f4f9f5;
    border-left-color: #0e6630;
    color: #14211a;
    text-decoration: none;
}

.gs-item__icon {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: #e8f3ec;
    color: #084a22;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    margin-top: 2px;
}

/* Per-type icon tint — subtle differentiation across the entity types */
.gs-item--lesson .gs-item__icon { background: #e8f3ec; color: #084a22; }
.gs-item--series .gs-item__icon { background: #e6eaf6; color: #2a3a86; }
.gs-item--theme  .gs-item__icon { background: #fbf3df; color: #8a5d12; }
.gs-item--vocab  .gs-item__icon { background: #fbe8e8; color: #8a3030; }
.gs-item--quiz   .gs-item__icon { background: #ede5fb; color: #4b2e94; }

.gs-item__body {
    flex: 1;
    min-width: 0;
}

.gs-item__title {
    font-size: 0.94rem;
    font-weight: 600;
    color: #14211a;
    line-height: 1.3;
    word-break: break-word;
    display: inline;
}

.gs-item__subtitle {
    font-size: 0.78rem;
    color: #4a5b51;
    margin-left: 8px;
    font-weight: 500;
}

.gs-item__snippet {
    margin: 2px 0 0 0;
    font-size: 0.82rem;
    color: #4a5b51;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

/* Highlighted matched term — used for title, subtitle, and snippet. */
.gs-item mark {
    background: #fff3a3;
    color: inherit;
    padding: 0 2px;
    border-radius: 2px;
    font-weight: 600;
}

/* ======== Footer (See-all link + tips) ======== */

.gs-footer {
    border-top: 1px solid #e0e8e3;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: #f8fbf9;
    font-size: 0.78rem;
    color: #4a5b51;
}

.gs-footer__seeall {
    color: #084a22;
    font-weight: 700;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.gs-footer__seeall:hover { color: #0e6630; text-decoration: underline; }

.gs-footer__hint {
    font-size: 0.76rem;
    color: #6a7770;
}

.gs-footer__hint kbd {
    display: inline-block;
    background: #fff;
    border: 1px solid #e0e8e3;
    border-radius: 4px;
    padding: 1px 6px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.72rem;
    color: #14211a;
    margin: 0 2px;
}

/* ======== Empty / no-results state ======== */

.gs-empty {
    text-align: center;
    padding: 28px 18px;
    color: #4a5b51;
}

.gs-empty i {
    display: block;
    font-size: 1.6rem;
    color: #0e6630;
    margin-bottom: 8px;
}

/* ======== Responsive ======== */

@media (max-width: 600px) {
    .gs-panel { width: calc(100vw - 16px); }
    .gs-item__subtitle { display: block; margin-left: 0; }
}
