/* ─── TrackEd Article Search Widget ─── */

.article-search-widget {
    --search-accent: #2563eb;
    --search-bg: #f8fafc;
    --search-border: #e2e8f0;
    --search-text: #334155;
    --search-muted: #94a3b8;
    --search-radius: 8px;
    --search-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;

    font-family: var(--search-font);
    position: sticky;
    top: 16px;
    z-index: 100;
    margin-bottom: 1.5em;
}

.article-search-container {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--search-bg);
    border: 1px solid var(--search-border);
    border-radius: var(--search-radius);
    padding: 6px 12px;
    transition: border-color 0.2s, box-shadow 0.2s;
    max-width: 520px;
}

.article-search-container:focus-within {
    border-color: var(--search-accent);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.article-search-icon {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    color: var(--search-muted);
}

.article-search-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 16px; /* Must be >=16px to prevent iOS Safari auto-zoom */
    color: var(--search-text);
    outline: none;
    padding: 6px 0;
    min-width: 0;
    font-family: var(--search-font);
}

.article-search-input::placeholder {
    color: var(--search-muted);
}

.article-search-meta {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.article-search-count {
    font-size: 12px;
    color: var(--search-muted);
    white-space: nowrap;
    min-width: 40px;
    text-align: center;
    user-select: none;
}

.article-search-nav {
    display: flex;
    gap: 2px;
}

.article-search-nav button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    border-radius: 4px;
    color: var(--search-muted);
    cursor: pointer;
    padding: 0;
    transition: background 0.15s, color 0.15s;
}

.article-search-nav button:hover:not(:disabled) {
    background: #e2e8f0;
    color: var(--search-text);
}

.article-search-nav button:disabled {
    opacity: 0.3;
    cursor: default;
}

.article-search-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    border-radius: 50%;
    color: var(--search-muted);
    cursor: pointer;
    padding: 0;
    transition: background 0.15s, color 0.15s;
}

.article-search-clear:hover {
    background: #e2e8f0;
    color: var(--search-text);
}

/* ─── Mark.js Highlight Styles ─── */

mark[data-markjs="true"] {
    background-color: #fef08a !important;
    color: #1e293b !important;
    padding: 1px 2px;
    border-radius: 2px;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
    scroll-margin-top: 60px; /* Clear the sticky search bar */
}

mark[data-markjs="true"].article-search-current {
    background-color: #fb923c !important;
    color: #1e293b !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

/* ─── Keyboard hint ─── */

.article-search-kbd {
    font-size: 11px;
    color: var(--search-muted);
    background: #fff;
    border: 1px solid var(--search-border);
    border-radius: 4px;
    padding: 1px 6px;
    font-family: var(--search-font);
    user-select: none;
    line-height: 1.6;
}

/* ─── Hide meta when no query ─── */

.article-search-meta[data-hidden="true"],
.article-search-clear[data-hidden="true"] {
    display: none;
}
