/* ============================================
   Live Search - Circulars (two-pane layout)
   ============================================ */

.lsc-wrap {
    font-family: 'Open Sans', sans-serif;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    color: #1f2937;
}

/* ---------- Header ---------- */
.lsc-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid #e5e7eb;
    background: #fafafa;
}
.lsc-summary { font-size: 13px; color: #6b7280; }
.lsc-summary strong { color: #111827; font-weight: 600; }
.lsc-filter {
    width: 220px;
    height: 30px;
    padding: 0 10px;
    font-size: 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    outline: none;
    background: #fff;
}
.lsc-filter:focus { border-color: #2563eb; box-shadow: 0 0 0 2px rgba(37,99,235,0.15); }

/* ---------- Category pills ---------- */
.lsc-cats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 14px;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
}
.lsc-cat {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 11px;
    font-size: 12px;
    line-height: 1.4;
    border: 1px solid #e5e7eb;
    background: #f3f4f6;
    color: #4b5563;
    border-radius: 999px;
    cursor: pointer;
    transition: all .15s ease;
    font-family: inherit;
}
.lsc-cat:hover { background: #e5e7eb; color: #1f2937; }
.lsc-cat.is-active {
    background: #2563eb;
    color: #fff;
    border-color: #2563eb;
}
.lsc-cat-n {
    display: inline-block;
    min-width: 18px;
    padding: 1px 6px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 999px;
    background: rgba(0,0,0,0.08);
}
.lsc-cat.is-active .lsc-cat-n { background: rgba(255,255,255,0.25); }

/* ---------- Body (two pane) ---------- */
.lsc-body {
    display: flex;
    max-height: 460px;
    min-height: 280px;
}

/* ---------- Years sidebar ---------- */
.lsc-years {
    width: 92px;
    flex-shrink: 0;
    border-right: 1px solid #e5e7eb;
    background: #fafafa;
    overflow-y: auto;
}
.lsc-years-label {
    padding: 10px 12px 6px;
    font-size: 10px;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.lsc-year-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 7px 12px;
    font-size: 15px;
    color: #6b7280;
    text-decoration: none;
    border-left: 2px solid transparent;
    cursor: pointer;
    transition: background .12s ease;
}
.lsc-year-link:hover { background: #f3f4f6; color: #111827; text-decoration: none; }
.lsc-year-link.is-active {
    background: #fff;
    color: #111827;
    font-weight: 600;
    border-left-color: #2563eb;
}
.lsc-year-n {
    font-size: 11px;
    font-weight: 500;
    color: #9ca3af;
}
.lsc-year-link.is-active .lsc-year-n { color: #2563eb; }

/* ---------- Results list ---------- */
.lsc-list {
    flex: 1;
    min-width: 0;
    overflow-y: auto;
    scroll-behavior: smooth;
}
.lsc-year-block { }
.lsc-year-hd {
    position: sticky;
    top: 0;
    z-index: 2;
    padding: 7px 16px;
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #f3f4f6;
    border-bottom: 1px solid #e5e7eb;
}
.lsc-year-hd span { color: #9ca3af; font-weight: 500; }

.lsc-row {
    display: flex;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid #f0f0f0;
    text-decoration: none;
    color: inherit;
    transition: background .12s ease;
}
.lsc-row:hover { background: #f9fafb; text-decoration: none; color: inherit; }
.lsc-row:last-child { border-bottom: 0; }

.lsc-badge {
    flex-shrink: 0;
    align-self: flex-start;
    font-size: 10px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
    line-height: 1.4;
    white-space: nowrap;
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* 8 badge color variants — assigned by category_id % 8 */
.lsc-badge-c0 { background: #ede9fe; color: #5b21b6; }
.lsc-badge-c1 { background: #fef3c7; color: #92400e; }
.lsc-badge-c2 { background: #fee2e2; color: #991b1b; }
.lsc-badge-c3 { background: #dcfce7; color: #166534; }
.lsc-badge-c4 { background: #dbeafe; color: #1e40af; }
.lsc-badge-c5 { background: #fce7f3; color: #9d174d; }
.lsc-badge-c6 { background: #ccfbf1; color: #115e59; }
.lsc-badge-c7 { background: #ffedd5; color: #9a3412; }

.lsc-row-body { flex: 1; min-width: 0; }
.lsc-row-top {
    display: flex;
    justify-content: space-between;
    gap: 10px;
    align-items: baseline;
}
.lsc-row-title {
    font-size: 15px;
    font-weight: 600;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.lsc-row-date { font-size: 11px; color: #9ca3af; flex-shrink: 0; }
.lsc-row-sub {
    margin-top: 2px;
    font-size: 14px;
    color: #6b7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.5;
}

/* Hidden state */
.lsc-row.is-hidden,
.lsc-year-block.is-hidden { display: none; }

.lsc-empty {
    padding: 30px 16px;
    text-align: center;
    font-size: 13px;
    color: #9ca3af;
}

.lsc-noresults {
    padding: 16px;
    font-size: 13px;
    color: #6b7280;
    line-height: 1.5;
}

/* Scrollbars */
.lsc-list::-webkit-scrollbar,
.lsc-years::-webkit-scrollbar { width: 8px; }
.lsc-list::-webkit-scrollbar-thumb,
.lsc-years::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }
.lsc-list::-webkit-scrollbar-thumb:hover,
.lsc-years::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ============================================
   Tablet (≤900px) — narrow the sidebar
   ============================================ */
@media ( max-width: 900px ) {
    .lsc-years { width: 78px; }
    .lsc-body { max-height: 440px; }
}

/* ============================================
   Mobile (≤640px) — hide sidebar, stack rows
   ============================================ */
@media ( max-width: 640px ) {
    .lsc-head {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding: 10px 12px;
    }
    .lsc-filter { width: 100%; height: 36px; font-size: 14px; }
    .lsc-summary { font-size: 12px; }

    .lsc-cats { padding: 8px 12px; gap: 5px; }
    .lsc-cat { font-size: 11px; padding: 5px 10px; }

    /* Hide the year sidebar — sticky year headers do the job */
    .lsc-years { display: none; }

    .lsc-body { max-height: 70vh; min-height: 240px; }

    .lsc-year-hd { padding: 8px 12px; font-size: 10px; }

    /* Rows: bigger touch targets + stack badge above content vertically */
    .lsc-row {
        padding: 12px;
        gap: 6px;
        flex-direction: column;
        align-items: stretch;
    }
    .lsc-badge {
        max-width: none;
        align-self: flex-start;
        font-size: 10px;
        padding: 3px 8px;
        white-space: normal;
        word-break: break-word;
        line-height: 1.35;
    }
    /* Title + date stack vertically on mobile */
    .lsc-row-top {
        flex-direction: column;
        gap: 2px;
        align-items: flex-start;
    }
    .lsc-row-title {
        font-size: 14px;
        white-space: normal;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        line-height: 1.35;
    }
    .lsc-row-date { font-size: 11px; }
    /* Allow subtitle to wrap to 2 lines */
    .lsc-row-sub {
        white-space: normal;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        font-size: 12px;
        line-height: 1.4;
        margin-top: 4px;
    }
}

/* Very small screens (≤380px) */
@media ( max-width: 380px ) {
    .lsc-head, .lsc-cats { padding-left: 10px; padding-right: 10px; }
    .lsc-row { padding: 12px 10px; }
    .lsc-cat { font-size: 11px; padding: 4px 9px; }
    .lsc-cat-n { padding: 1px 5px; min-width: 16px; }
}
