/* mv6 통합검색 AI영역 — v4 search.css 의 AI 규칙 포팅 (원본 수정 시 함께 갱신) */
@keyframes colorShift {
    0%   { --fa-primary-color: #ff0080; --fa-secondary-color: #ff0080; }
    20%  { --fa-primary-color: #ff0080; --fa-secondary-color: #ff0080; }
    25%  { --fa-primary-color: #00eaff; --fa-secondary-color: #00eaff; }
    45%  { --fa-primary-color: #00eaff; --fa-secondary-color: #00eaff; }
    50%  { --fa-primary-color: #7cff00; --fa-secondary-color: #7cff00; }
    70%  { --fa-primary-color: #7cff00; --fa-secondary-color: #7cff00; }
    75%  { --fa-primary-color: #ffd000; --fa-secondary-color: #ffd000; }
    95%  { --fa-primary-color: #ffd000; --fa-secondary-color: #ffd000; }
    100% { --fa-primary-color: #ff0080; --fa-secondary-color: #ff0080; }
}
#sparkle {
    animation: colorShift 4s ease-in-out infinite;
    filter: drop-shadow(0 0 8px currentColor);
}

/* ── AI 답변 ── */
.ai-answer-section {
    font-size: 0.92rem;
    line-height: 1.85;
    color: var(--bs-body-color);
}

/* 마크다운 헤딩 */
.ai-answer-section .md-h1 {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 2rem 0 0.5rem;
    color: var(--bs-body-color);
    border-bottom: 1px solid var(--bs-primary);
    padding-bottom: 0.3rem;
}
.ai-answer-section .md-h2 {
    font-size: 1rem;
    font-weight: 700;
    margin: 2rem 0 0.4rem;
    color: var(--bs-body-color);
    border-bottom: 0.1px solid var(--bs-gray-300);
    padding-bottom: 0.25rem;
}
.ai-answer-section .md-h3 {
    font-size: 0.92rem;
    font-weight: 700;
    margin: 2rem 0 0.35rem;
    color: var(--bs-primary);
}

/* 문단 */
.ai-answer-section .md-p {
    margin: 0 0 0.7rem;
    line-height: 1.85;
}

/* 리스트 */
.ai-answer-section .md-ul {
    list-style: disc;
    padding-left: 1.5rem;
    margin: 0.3rem 0 0.7rem;
}
.ai-answer-section .md-ul li,
.ai-answer-section .md-ol li {
    margin-bottom: 0.3rem;
    line-height: 1.7;
}
.ai-answer-section .md-ul li:last-child,
.ai-answer-section .md-ol li:last-child {
    margin-bottom: 0;
}

/* 순서 목록은 요약 박스로 강조 */
.ai-answer-section .md-ol {
    list-style: decimal;
    background: var(--bs-gray-100);
    border: 0.1px solid var(--bs-gray-200);
    border-radius: 12px;
    padding: 16px 20px 16px 2.4rem;
    margin: 0.5rem 0 1rem;
    font-weight: 600;
}

/* 인용 */
.ai-answer-section .md-bq {
    border-left: 3px solid var(--bs-primary);
    background: var(--bs-gray-100);
    margin: 0.6rem 0;
    padding: 0.5rem 1rem;
    border-radius: 0 6px 6px 0;
    color: var(--bs-gray-700);
    font-style: italic;
}
.ai-answer-section .md-bq p { margin: 0; }

/* 구분선 */
.ai-answer-section .md-hr {
    border: none;
    border-top: 1px solid var(--bs-gray-300);
    margin: 0.8rem 0;
}

/* 인라인 코드 */
.ai-answer-section .md-code {
    background: var(--bs-gray-100);
    border: 0.1px solid var(--bs-gray-300);
    border-radius: 4px;
    padding: 0.1em 0.4em;
    font-size: 0.85em;
    font-family: monospace;
    color: #c7254e;
}

/* 링크 */
.ai-answer-section .md-link {
    color: var(--bs-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.ai-answer-section .md-link:hover { opacity: 0.75; }

/* [참조] 텍스트 (URL 없는 링크) */
.ai-answer-section .md-ref {
    font-weight: 600;
    color: var(--bs-body-color);
}

/* ── AI 참고 자료 섹션 ── */
.ai-sources-section {
    margin-top: 32px;
    border-top: 1px solid var(--bs-gray-200);
    padding-top: 24px;
}
/* AI 답변 내 h3(예: '추천 설교', .md-h3)와 동일한 스타일 */
.ai-sources-header {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--bs-primary);
    margin-bottom: 14px;
}

/* 참고자료 카드(관련설교·궁금해요) — 카드 하단 여백 */
.ai-source-content .post {
    margin-bottom: 32px;
}

/* 탭 — 세그먼트(알약) 안에 세로형 버튼(아이콘 위·라벨 아래), 건수 뱃지는 버튼 오른쪽 위 모서리
   카테고리 4개(Q&A·설교·성경·궁금해요)가 320px 폰에서도 한 줄에 들어가도록 글자 0.78rem + nowrap.
   마크업은 search_ai.js buildAiSourcesHtml() 참고 */
.ai-source-tabs {
    display: flex;          /* 모바일 — 가로 전체 사용 */
    width: 100%;
    gap: 2px;
    padding: 4px;
    background: var(--bs-gray-100);
    border: 0;
    border-radius: 999px;
    margin: 8px 0 16px;     /* 위 8px — 알약 위로 튀어나오는 건수 뱃지 자리 */
}
.ai-source-tabs .nav-item { margin: 0; flex: 1; min-width: 0; }   /* 탭들이 균등하게 넓게 */
.ai-source-tabs .nav-link {
    position: relative;         /* 건수 뱃지 기준 */
    width: 100%;
    display: flex;
    flex-direction: column;     /* 아이콘 위, 라벨 아래 */
    align-items: center;
    justify-content: center;
    gap: 2px;                   /* 아이콘↔라벨 간격 */
    text-align: center;
    font-size: 0.78rem;
    font-weight: 600;
    white-space: nowrap;
    color: var(--bs-gray-600);
    padding: 5px 4px 4px;       /* 위아래 여백은 작게(2026-10-21 사장님 지시로 8/7 → 5/4) */
    border: 0 !important;
    border-radius: 999px;
    background: transparent;
    transition: color .18s ease, background .18s ease, box-shadow .18s ease;
}
.ai-source-tabs .nav-link i {
    font-size: 1.05rem;
    line-height: 1;
    color: var(--bs-gray-500);
}
.ai-source-tabs .nav-link:hover {
    color: var(--bs-gray-800);
}
.ai-source-tabs .nav-link.active {
    color: var(--bs-primary);
    background: #fff;
    box-shadow: 0 1px 5px rgba(15, 30, 60, .10);
}
.ai-source-tabs .nav-link.active i {
    color: var(--bs-primary);
}
.ai-source-tabs .nav-link .badge {
    position: absolute;         /* 버튼 오른쪽 위 모서리에 걸침 */
    top: -5px;
    right: 6px;
    margin: 0;
    font-size: 0.58rem;
    font-weight: 700;
    line-height: 1;
    padding: 3px 5px;
    min-width: 17px;
    background: var(--bs-primary) !important;
    color: #fff !important;
    box-shadow: 0 0 0 2px #fff; /* 알약 배경과 떨어져 보이게 흰 테두리 */
}

.ai-source-content {
    border: 0;
    padding: 0;
    background: transparent;
}

/* 개별 문서 카드 */
.ai-source-doc {
    padding: 16px 18px;
    margin-bottom: 12px;
    border-radius: 14px;
    background: #fff;
    border: 1px solid var(--bs-gray-200);
    transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.ai-source-doc:hover {
    border-color: color-mix(in srgb, var(--bs-primary) 35%, var(--bs-gray-200));
    box-shadow: 0 8px 20px rgba(15, 30, 60, .07);
    transform: translateY(-1px);
}
.ai-source-doc:last-child {
    margin-bottom: 2px;
}

.ai-rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--bs-primary) 10%, #fff);
    color: var(--bs-primary);
    font-size: 0.66rem;
    font-weight: 700;
    margin-right: 8px;
    vertical-align: middle;
    flex-shrink: 0;
}

.ai-source-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--bs-body-color);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
}
.ai-source-preview {
    font-size: 0.8rem;
    color: var(--bs-gray-600);
    line-height: 1.7;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.ai-source-meta {
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.ai-source-date {
    font-size: 0.72rem;
    color: var(--bs-gray-500);
}
.ai-source-link {
    font-size: 0.72rem;
    color: var(--bs-primary);
    text-decoration: none;
    font-weight: 500;
}
.ai-source-link:hover {
    text-decoration: underline;
}.ai-citation-link {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    color: #333;
    background-color: #e8e8e8;
    border-radius: 3px;
    padding: 0 4px;
    line-height: 1.6;
    text-decoration: none;
    vertical-align: middle;
    margin: 0 1px;
}
.ai-citation-link:hover {
    background-color: #d0d0d0;
    text-decoration: none;
    color: #333;
}
/* 참조 옆 카테고리 라벨 */
.ai-citation-link .ai-citation-cat {
    margin-left: 4px;
    padding-left: 4px;
    border-left: 1px solid rgba(0,0,0,.18);
    font-weight: 700;
}
/* 카테고리별 색상 */
.ai-citation-link[data-src="sermon"]   { background-color:#e3ecfb; color:#1b4fa0; }
.ai-citation-link[data-src="sermon"]:hover   { background-color:#d2e0f6; color:#1b4fa0; }
.ai-citation-link[data-src="qa"]       { background-color:#e0f3f6; color:#0c6b78; }
.ai-citation-link[data-src="qa"]:hover       { background-color:#cfeaef; color:#0c6b78; }
.ai-citation-link[data-src="bible"]    { background-color:#e3f4e6; color:#1f7a37; }
.ai-citation-link[data-src="bible"]:hover    { background-color:#d2ecd7; color:#1f7a37; }
.ai-citation-link[data-src="lifepost"] { background-color:#fdf0db; color:#9a6300; }
.ai-citation-link[data-src="lifepost"]:hover { background-color:#fbe7c4; color:#9a6300; }

/* 검색결과 카테고리 바로가기 버튼 바 (헤더 아래 고정) */
.search-cats {
    position: sticky;
    top: 3rem; /* #page-header 높이 */
    z-index: 1080;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 0;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.92);
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    border-bottom: 1px solid var(--bs-gray-300);
}
.search-cats .cat-btn {
    cursor: pointer;
    border: 1px solid var(--bs-gray-300);
    background: #fff;
    color: var(--bs-gray-700);
    border-radius: 50rem;
    padding: 5px 14px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    transition: background-color .15s, border-color .15s, color .15s;
}
.search-cats .cat-btn:hover {
    background: var(--bs-primary);
    border-color: var(--bs-primary);
    color: #fff;
}
.search-cats .cat-btn .cat-count {
    margin-left: 5px;
    opacity: .65;
    font-weight: 500;
}

/* AI 스트리밍 타이핑 커서 */
.ai-stream-cursor {
    display: inline-block;
    margin-left: 2px;
    color: var(--bs-primary, #333);
    animation: aiCursorBlink 1s steps(2, start) infinite;
}
@keyframes aiCursorBlink {
    to { visibility: hidden; }
}

