/* ========================================
   IFTA TOPICS - v3.0 groups + filters + INLINE NAV
   ======================================== */

.ifta-main {
    flex: 1;
    padding: 0 20px 80px;
}

.ifta-topics-section {
    max-width: 1200px;
    margin: 0 auto;
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.ifta-topics-section.search-hidden {
    opacity: 0;
    transform: translateY(6px);
    pointer-events: none;
    height: 0;
    overflow: hidden;
    margin: 0;
    padding: 0;
}

.ifta-topics-container {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.ifta-topics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

/* ========================================
   FILTER PILLS
   ======================================== */

.topics-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 0 32px;
    align-items: center;
}

/* Мобильные: горизонтальный скролл вместо переноса */
@media (max-width: 768px) {
    .topics-filters {
        flex-wrap: nowrap;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        padding-bottom: 12px;
        -webkit-mask-image: linear-gradient(to right, transparent 0px, black 12px, black calc(100% - 40px), transparent 100%);
        mask-image: linear-gradient(to right, transparent 0px, black 12px, black calc(100% - 40px), transparent 100%);
    }
    .topics-filters::-webkit-scrollbar { display: none; }
    .filter-pill-main {
        flex-shrink: 0;
        white-space: nowrap;
    }
}

.filter-pill-main {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 50px;
    border: 2px solid var(--border-gray);
    background: var(--white);
    color: var(--medium-gray);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.filter-pill-main:hover {
    border-color: var(--pill-color, var(--emerald));
    color: var(--pill-color, var(--emerald));
    background: var(--pill-color-light, var(--emerald-50));
}

.filter-pill-main.active {
    border-color: var(--pill-color, var(--emerald));
    background: var(--pill-color, var(--emerald));
    color: var(--on-primary);
}

.pill-icon {
    font-size: 16px;
    line-height: 1;
}

.pill-count {
    font-size: 11px;
    background: rgba(0,0,0,0.08);
    padding: 1px 7px;
    border-radius: 20px;
    font-weight: 600;
}

.filter-pill-main.active .pill-count {
    background: rgba(255,255,255,0.25);
}

/* ========================================
   GROUP SECTION
   ======================================== */

.topics-content {
    display: flex;
    flex-direction: column;
}

.topics-group {
    margin-bottom: 48px;
}

.topics-group:last-child {
    margin-bottom: 0;
}

.topics-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 2px solid var(--light-gray);
}

.group-header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.group-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.group-title-block {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.group-title {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.2;
    margin: 0;
}

.group-title-ar {
    font-family: var(--font-arabic);
    font-size: 15px;
    color: var(--medium-gray);
    direction: rtl;
    line-height: 1;
}

.group-count {
    font-size: 12px;
    color: var(--medium-gray);
    background: var(--light-gray);
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 500;
    white-space: nowrap;
}

/* ========================================
   TOPIC CARD
   ======================================== */

.ifta-topic-card {
    background: var(--white);
    border: 2px solid var(--border-gray);
    border-radius: 16px;
    padding: 22px;
    cursor: pointer;
    transition: border-color 0.25s ease, box-shadow 0.25s ease, transform 0.25s ease;
    box-shadow: 0 2px 12px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    animation: cardFadeIn 0.4s ease both;
    position: relative;
    overflow: hidden;
    height: 170px;
}

.ifta-topic-card::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--card-accent, var(--emerald));
    border-radius: 16px 0 0 16px;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.ifta-topic-card:hover::before {
    opacity: 1;
}

@keyframes cardFadeIn {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ifta-topic-card:hover {
    border-color: var(--card-accent, var(--emerald));
    box-shadow: 0 6px 28px rgba(0,0,0,0.1);
    transform: translateY(-3px);
}

.ifta-topic-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    gap: 8px;
}

.ifta-topic-title-wrap {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    flex: 1;
    min-width: 0;
}

.ifta-topic-icon {
    font-size: 18px;
    line-height: 1.4;
    flex-shrink: 0;
}

.ifta-topic-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--dark-gray);
    transition: color 0.2s ease;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: calc(16px * 1.4 * 2);
}

.ifta-topic-card:hover .ifta-topic-title {
    color: var(--card-accent, var(--emerald));
}

.ifta-topic-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.ifta-topic-code {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--card-accent, var(--emerald));
    background: var(--card-accent-light, var(--emerald-50));
    padding: 2px 7px;
    border-radius: 4px;
}

.ifta-topic-count {
    font-size: 11px;
    color: var(--medium-gray);
    font-weight: 500;
    background: var(--light-gray);
    padding: 2px 7px;
    border-radius: 10px;
}

.ifta-topic-tags {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    margin-top: 8px;
    margin-bottom: 14px;
    overflow: hidden;
    height: 26px;
    flex-shrink: 0;
}

.ifta-tag {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 20px;
    background: var(--light-gray);
    color: var(--medium-gray);
    font-weight: 500;
}

.ifta-topic-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-top: 1px solid var(--light-gray);
    padding-top: 12px;
    margin-top: auto;
}

.ifta-topic-view {
    font-size: 12px;
    font-weight: 600;
    color: var(--card-accent, var(--emerald));
    letter-spacing: 0.01em;
}

.ifta-topic-arrow {
    color: var(--card-accent, var(--emerald));
    transition: transform 0.2s ease;
}

.ifta-topic-card:hover .ifta-topic-arrow {
    transform: translateX(3px);
}

.ifta-topic-arrow svg {
    width: 16px;
    height: 16px;
}

/* ========================================
   INLINE NAVIGATION (v3.0)
   Books → Chapters → Questions rendered on page
   ======================================== */

.ifta-inline-nav {
    max-width: 800px;
    margin: 0 auto;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.35s ease, transform 0.35s ease;
}

/* На LEVEL 3 (список фетв карточками) расширяем контейнер,
   чтобы карточки занимали всё пространство */
.ifta-inline-nav.has-fatwa-grid {
    max-width: 1400px;
}

.ifta-inline-nav.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ── Breadcrumb ── */
.inline-breadcrumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 24px;
    font-size: 13px;
    font-weight: 500;
}

.bc-item {
    color: #6b7280;
    transition: color 0.2s;
}

.bc-link {
    cursor: pointer;
    color: #059669;
}

.bc-link:hover {
    color: var(--emerald-dark, #047857);
    text-decoration: underline;
}

.bc-current {
    color: #111827;
    font-weight: 600;
}

.bc-sep {
    color: #d1d5db;
    font-size: 14px;
    margin: 0 2px;
    user-select: none;
}

/* ── Header ── */
.inline-header {
    margin-bottom: 28px;
}

.inline-title {
    font-size: 28px;
    font-weight: 800;
    color: #111827;
    margin: 0 0 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    line-height: 1.3;
    animation: inlineTitleFade 0.4s ease both;
}

@keyframes inlineTitleFade {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.inline-title-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.inline-desc {
    font-size: 14px;
    color: #6b7280;
    margin: 0;
}

.inline-desc strong {
    color: #374151;
}

/* ── Inline search ── */
.inline-search-wrap {
    position: relative;
    margin-bottom: 20px;
}

.inline-search-input {
    width: 100%;
    padding: 12px 16px 12px 40px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 14px;
    font-family: inherit;
    color: #111827;
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    box-sizing: border-box;
}

.inline-search-input:focus {
    border-color: #059669;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--emerald) 10%, transparent);
}

.inline-search-input::placeholder {
    color: #9ca3af;
}

.inline-search-icon {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    pointer-events: none;
    line-height: 0;
}

/* ── Inline filters ── */
.inline-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.inline-filters .filter-pill {
    display: inline-block;
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid #e5e7eb;
    background: #fff;
    color: #6b7280;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.inline-filters .filter-pill:hover {
    border-color: #059669;
    color: #059669;
}

.inline-filters .filter-pill.active {
    background: #059669;
    border-color: #059669;
    color: #fff;
}

/* ── Inline list ── */
.inline-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.inline-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #fff;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.2s, transform 0.15s;
    animation: inlineItemFade 0.3s ease both;
    border: 1px solid transparent;
}

@keyframes inlineItemFade {
    from { opacity: 0; transform: translateX(-8px); }
    to   { opacity: 1; transform: translateX(0); }
}

.inline-list-item:hover {
    background: var(--emerald-50, #ecfdf5);
    border-color: color-mix(in srgb, var(--emerald, #059669) 30%, transparent);
    box-shadow: 0 2px 8px color-mix(in srgb, var(--emerald, #059669) 10%, transparent);
    transform: translateX(4px);
}

.inline-list-item--fatwa {
    border: 1px solid #f3f4f6;
}

.inline-list-item--fatwa:hover {
    border-color: color-mix(in srgb, var(--emerald, #059669) 30%, transparent);
}

.inline-item-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.inline-item-title {
    font-size: 15px;
    font-weight: 500;
    color: #111827;
    line-height: 1.4;
}

.inline-item-count {
    font-size: 11px;
    color: #9ca3af;
    font-weight: 500;
}

.inline-item-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.inline-mini-tag {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    background: #f3f4f6;
    color: #6b7280;
    font-weight: 500;
}

.inline-item-arrow {
    flex-shrink: 0;
    color: #059669;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    margin-inline-start: 12px;
}

.inline-list-item:hover .inline-item-arrow {
    transform: translateX(3px);
}

/* Закладка в списке фетв */
.inline-item-bookmark {
    flex-shrink: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: #aaa;
    padding: 4px;
    margin-inline-start: 4px;
    display: flex;
    align-items: center;
    transition: color 0.2s;
    border-radius: 4px;
}
.inline-item-bookmark:hover {
    color: var(--gold, #d4a017);
}
.inline-item-bookmark.active {
    color: var(--gold, #d4a017);
}
.inline-item-bookmark.active svg {
    fill: var(--gold, #d4a017);
}

/* ── Empty state ── */
.inline-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 48px 24px 32px;
    gap: 12px;
}

.inline-empty-icon {
    font-size: 48px;
    line-height: 1;
    margin-bottom: 4px;
}

.inline-empty-title {
    font-size: 16px;
    font-weight: 700;
    color: #111827;
}

.inline-empty-sub {
    font-size: 13px;
    color: #6b7280;
    max-width: 280px;
    line-height: 1.5;
}

.inline-empty-cta {
    margin-top: 8px;
    padding: 10px 22px;
    background: #059669;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s, transform 0.12s;
    font-family: inherit;
}

.inline-empty-cta:hover {
    background: var(--emerald-dark, #047857);
    transform: translateY(-1px);
}

/* ── Loading spinner for inline ── */
.inline-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 0;
}

/* ========================================
   RESPONSIVE - INLINE NAV
   ======================================== */

@media (max-width: 768px) {
    .ifta-inline-nav {
        padding: 0 4px;
    }

    .inline-title {
        font-size: 22px;
    }

    .inline-title-icon {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }

    .inline-list-item {
        padding: 14px 16px;
    }
    
    .inline-breadcrumb {
        font-size: 12px;
    }
}

@media (max-width: 640px) {
    .inline-title {
        font-size: 20px;
    }
}

/* ========================================
   BOOK NAVIGATION ARROWS
   prev / next book — стрелки между книгами
   ======================================== */

.book-nav-arrows {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
}

.book-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 14px;
    border: 1.5px solid #d1fae5;
    border-radius: 10px;
    background: #fff;
    color: #059669;
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.12s ease;
    max-width: calc(50% - 4px);
    min-width: 0;
    line-height: 1;
}

.book-nav-btn:hover {
    background: var(--emerald-50, #ecfdf5);
    border-color: var(--emerald, #059669);
    box-shadow: 0 2px 10px color-mix(in srgb, var(--emerald, #059669) 15%, transparent);
}

.book-nav-btn:active {
    transform: scale(0.96);
}

.book-nav-label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.book-nav-icon {
    flex-shrink: 0;
    color: #059669;
}

/* На очень маленьких экранах — только иконка */
@media (max-width: 480px) {
    .book-nav-btn {
        padding: 9px 11px;
    }
    .book-nav-label {
        display: none;
    }
}

/* ── Анимации слайда ── */

@keyframes bookSlideInRight {
    from { opacity: 0; transform: translateX(52px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes bookSlideInLeft {
    from { opacity: 0; transform: translateX(-52px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes bookSlideOutLeft {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(-52px); }
}

@keyframes bookSlideOutRight {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(52px); }
}

.book-slide-in-right {
    animation: bookSlideInRight 0.35s ease both;
}

.book-slide-in-left {
    animation: bookSlideInLeft 0.35s ease both;
}

.book-slide-out-left {
    animation: bookSlideOutLeft 0.24s ease both;
    pointer-events: none;
    overflow: hidden;
}

.book-slide-out-right {
    animation: bookSlideOutRight 0.24s ease both;
    pointer-events: none;
    overflow: hidden;
}

/* ========================================
   INLINE FATWA CARDS (LEVEL 3 — список фетв в главе)
   ======================================== */
.inline-fatwa-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.inline-fatwa-card {
    position: relative;
    background: #fff;
    border: 1.5px solid var(--border-gray, #e5e7eb);
    border-radius: 12px;
    padding: 14px 16px 12px;
    min-height: 118px;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    transition: border-color .2s, transform .2s, box-shadow .2s, background .2s;
    animation: inlineItemFade .3s ease both;
}
.inline-fatwa-card:hover {
    border-color: var(--emerald, #059669);
    background: #f7fbf9;
    transform: translateY(-2px);
    box-shadow: 0 4px 14px color-mix(in srgb, var(--emerald) 10%, transparent);
}

.inline-fatwa-card-title {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    color: var(--dark-gray, #1f2937);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    padding-inline-end: 26px; /* место для кнопки-закладки */
    margin-bottom: auto;
}

.inline-fatwa-card-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.inline-fatwa-card-bookmark {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: var(--medium-gray, #9ca3af);
    cursor: pointer;
    transition: color .15s, background .15s;
}
.inline-fatwa-card-bookmark svg {
    transition: fill .15s;
}
.inline-fatwa-card-bookmark:hover {
    color: var(--emerald, #059669);
    background: color-mix(in srgb, var(--emerald) 8%, transparent);
}
.inline-fatwa-card-bookmark.active {
    color: var(--gold, #d4af37);
    background: rgba(212, 175, 55, 0.15);
}
.inline-fatwa-card-bookmark.active svg {
    fill: currentColor;
}

@media (max-width: 680px) {
    .inline-fatwa-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .inline-fatwa-card {
        min-height: auto;
    }
}
/* ── SVG-иконки (lucide-стиль) вместо emoji: размер 1em от font-size контейнера ── */
.pill-icon svg,
.ifta-topic-icon svg,
.inline-empty-icon svg {
    vertical-align: -0.125em;
}

.group-icon svg,
.inline-title-icon svg {
    display: block;
}
