/* Books catalog page. Colors follow style.css (#6C5DD3 / #11142D). */
.ct {
    --ct-brand: #6C5DD3;
    --ct-brand-dark: #5546c2;
    --ct-brand-soft: #F0EEFF;
    --ct-ink: #11142D;
    --ct-muted: #808191;
    --ct-faint: #B2B3BD;
    --ct-border: #ECECF2;
    --ct-surface-2: #F7F7FB;
    padding: 8px 0 40px;
    color: var(--ct-ink);
}

/* ---------------------------------------------------------- header + tabs */

.ct-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.ct-head h1 {
    margin: 0;
    font-size: 32px;
    font-weight: 700;
    line-height: 1.15;
}

.ct-head__count {
    margin: 6px 0 0;
    font-size: 14px;
    color: var(--ct-muted);
}

.ct-tabs {
    display: inline-flex;
    gap: 4px;
    padding: 4px;
    background: var(--ct-surface-2);
    border: 1px solid var(--ct-border);
    border-radius: 14px;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
}

.ct-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    border-radius: 10px;
    color: var(--ct-muted);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: background .15s, color .15s, box-shadow .15s;
}

.ct-tab:hover {
    color: var(--ct-ink);
}

.ct-tab em {
    font-style: normal;
    font-size: 12px;
    padding: 1px 8px;
    border-radius: 999px;
    background: #E9E9F1;
    color: var(--ct-muted);
}

.ct-tab.active {
    background: #fff;
    color: var(--ct-brand);
    box-shadow: 0 1px 4px rgba(17, 20, 45, .1);
}

.ct-tab.active em {
    background: var(--ct-brand-soft);
    color: var(--ct-brand);
}

/* ---------------------------------------------------------- layout */

.ct-layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

/* ---------------------------------------------------------- filters */

.ct-filters {
    position: sticky;
    top: 16px;
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid var(--ct-border);
    border-radius: 18px;
    overflow: hidden;
}

.ct-filters__head,
.ct-filters__foot {
    display: none;
}

.ct-filters__body {
    overflow-y: auto;
    padding: 6px 0;
    scrollbar-width: thin;
}

.ct-group {
    padding: 4px 16px 12px;
    border-bottom: 1px solid var(--ct-border);
}

.ct-group:last-child {
    border-bottom: 0;
}

.ct-group summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0 8px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
}

.ct-group summary::-webkit-details-marker {
    display: none;
}

.ct-group summary .fa-solid {
    font-size: 12px;
    color: var(--ct-faint);
    transition: transform .2s;
}

.ct-group:not([open]) summary .fa-solid {
    transform: rotate(-90deg);
}

.ct-options {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ct-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 7px 8px;
    margin: 0 -8px;
    border-radius: 10px;
    cursor: pointer;
    transition: background .15s;
}

.ct-check:hover {
    background: var(--ct-surface-2);
}

.ct-check input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.ct-check__box {
    flex: 0 0 18px;
    height: 18px;
    margin-top: 1px;
    border: 2px solid #D3D3DE;
    border-radius: 6px;
    background: #fff;
    position: relative;
    transition: background .15s, border-color .15s;
}

.ct-check input:checked + .ct-check__box {
    background: var(--ct-brand);
    border-color: var(--ct-brand);
}

.ct-check input:checked + .ct-check__box::after {
    content: "";
    position: absolute;
    left: 4px;
    top: 0;
    width: 6px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.ct-check input:focus-visible + .ct-check__box {
    box-shadow: 0 0 0 3px rgba(108, 93, 211, .25);
}

.ct-check__label {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    line-height: 1.35;
}

.ct-check input:checked ~ .ct-check__label {
    font-weight: 600;
    color: var(--ct-brand);
}

.ct-check__count {
    flex-shrink: 0;
    font-size: 12px;
    color: var(--ct-faint);
    padding-top: 2px;
}

.ct-search-in {
    position: relative;
    margin-bottom: 8px;
}

.ct-search-in .fa-solid {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 13px;
    color: var(--ct-faint);
}

.ct-search-in input {
    width: 100%;
    height: 38px;
    padding: 0 12px 0 34px;
    border: 1px solid var(--ct-border);
    border-radius: 10px;
    background: var(--ct-surface-2);
    font-size: 13.5px;
    outline: none;
    transition: border-color .15s, background .15s, box-shadow .15s;
}

.ct-search-in input:focus {
    background: #fff;
    border-color: var(--ct-brand);
    box-shadow: 0 0 0 3px rgba(108, 93, 211, .15);
}

.ct-options--authors .ct-check.is-extra,
.ct-options--authors .ct-check.is-hidden {
    display: none;
}

.ct-options--authors.is-expanded .ct-check.is-extra,
.ct-options--authors.is-searching .ct-check.is-extra {
    display: flex;
}

.ct-options--authors.is-searching .ct-check.is-hidden {
    display: none;
}

.ct-options__empty {
    display: none;
    margin: 4px 0;
    font-size: 13px;
    color: var(--ct-muted);
}

.ct-options--authors.is-empty .ct-options__empty {
    display: block;
}

.ct-more {
    margin-top: 6px;
    padding: 4px 0;
    border: 0;
    background: none;
    color: var(--ct-brand);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
}

.ct-backdrop {
    display: none;
}

/* ---------------------------------------------------------- toolbar */

.ct-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}

.ct-filter-btn {
    display: none !important;
}

.ct-filter-btn em {
    font-style: normal;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--ct-brand);
    color: #fff;
    font-size: 11px;
    line-height: 20px;
}

.ct-search {
    position: relative;
    flex: 1;
    min-width: 0;
}

.ct-search .fa-solid {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ct-faint);
    font-size: 14px;
}

.ct-search input {
    width: 100%;
    height: 44px;
    padding: 0 14px 0 40px;
    border: 1px solid var(--ct-border);
    border-radius: 12px;
    background: #fff;
    font-size: 14px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.ct-search input:focus {
    border-color: var(--ct-brand);
    box-shadow: 0 0 0 3px rgba(108, 93, 211, .15);
}

.ct-sort {
    position: relative;
    flex-shrink: 0;
    margin: 0;
}

.ct-sort .fa-solid {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ct-brand);
    font-size: 14px;
    pointer-events: none;
}

.ct-sort select {
    height: 44px;
    padding: 0 36px 0 40px;
    border: 1px solid var(--ct-border);
    border-radius: 12px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23808191' stroke-width='1.5' fill='none'/%3E%3C/svg%3E") no-repeat right 14px center;
    font-size: 14px;
    font-weight: 600;
    color: var(--ct-ink);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    outline: none;
}

.ct-sort select:focus {
    border-color: var(--ct-brand);
}

.ct-view {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--ct-border);
    border-radius: 12px;
    background: #fff;
}

.ct-icon-btn {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--ct-muted);
    font-size: 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s, color .15s;
}

.ct-icon-btn:hover {
    color: var(--ct-ink);
}

.ct-icon-btn.active {
    background: var(--ct-brand-soft);
    color: var(--ct-brand);
}

/* ---------------------------------------------------------- chips */

.ct-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.ct-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    padding: 6px 10px 6px 12px;
    border-radius: 999px;
    background: var(--ct-brand-soft);
    color: var(--ct-brand);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    transition: background .15s, color .15s;
}

.ct-chip span:first-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ct-chip:hover {
    background: var(--ct-brand);
    color: #fff;
}

.ct-chip-clear {
    font-size: 13px;
    font-weight: 600;
    color: var(--ct-muted);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.ct-chip-clear:hover {
    color: var(--ct-ink);
}

/* ---------------------------------------------------------- buttons */

.ct-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 40px;
    padding: 0 16px;
    border-radius: 12px;
    border: 1px solid transparent;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    cursor: pointer;
    transition: background .15s, color .15s, border-color .15s;
}

.ct-btn--primary {
    background: var(--ct-brand);
    color: #fff;
}

.ct-btn--primary:hover {
    background: var(--ct-brand-dark);
    color: #fff;
}

.ct-btn--ghost {
    background: #fff;
    border-color: var(--ct-border);
    color: var(--ct-ink);
}

.ct-btn--ghost:hover {
    border-color: var(--ct-faint);
    color: var(--ct-ink);
}

.ct-btn--soft {
    height: 36px;
    padding: 0 14px;
    background: var(--ct-brand-soft);
    color: var(--ct-brand);
    font-size: 13px;
}

.ct-btn--soft:hover {
    background: var(--ct-brand);
    color: #fff;
}

/* ---------------------------------------------------------- cards */

.ct-main {
    min-width: 0;
    transition: opacity .2s;
}

.ct-main.is-loading {
    opacity: .5;
    pointer-events: none;
}

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

.ct-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid var(--ct-border);
    border-radius: 18px;
    overflow: hidden;
    transition: border-color .2s, box-shadow .2s, transform .2s;
}

.ct-card:hover {
    border-color: #DDD9F7;
    box-shadow: 0 12px 30px rgba(17, 20, 45, .08);
    transform: translateY(-3px);
}

.ct-card__cover {
    position: relative;
    display: block;
    aspect-ratio: 3 / 4;
    margin: 12px 12px 0;
    border-radius: 12px;
    overflow: hidden;
    background: var(--ct-surface-2);
}

.ct-card__cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .3s;
}

.ct-card:hover .ct-card__cover img {
    transform: scale(1.03);
}

.ct-badge {
    position: absolute;
    left: 8px;
    top: 8px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
}

.ct-badge--audio {
    background: rgba(17, 20, 45, .78);
    color: #fff;
}

.ct-card__progress {
    position: absolute;
    left: 8px;
    right: 8px;
    bottom: 8px;
    height: 5px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .75);
    overflow: hidden;
}

.ct-card__progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--ct-brand);
}

.ct-card__body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 12px 14px 14px;
}

.ct-card__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 10px;
    margin-bottom: 6px;
}

.ct-card__tags a {
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .02em;
    color: var(--ct-brand);
    text-decoration: none;
}

.ct-card__title {
    font-size: 15px;
    font-weight: 700;
    line-height: 1.35;
    color: var(--ct-ink);
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ct-card__title:hover {
    color: var(--ct-brand);
}

.ct-card__author {
    margin-top: 4px;
    font-size: 13px;
    color: var(--ct-muted);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ct-card__author:hover {
    color: var(--ct-brand);
}

.ct-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    margin-top: 8px;
    font-size: 12.5px;
    color: var(--ct-muted);
}

.ct-card__meta > span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.ct-card__meta .fa-solid,
.ct-card__meta .fa-regular {
    font-size: 11px;
    color: var(--ct-faint);
}

.ct-card__rating {
    font-weight: 700;
    color: var(--ct-ink) !important;
}

.ct-card__rating .fa-solid {
    color: #F59E0B !important;
}

.ct-card__desc {
    display: none;
}

.ct-card__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: auto;
    padding-top: 12px;
}

.ct-card__foot .ct-btn {
    margin-left: auto;
}

.ct-card__percent {
    white-space: nowrap;
    font-size: 12px;
    font-weight: 700;
    color: var(--ct-brand);
}

/* list view */
.ct-grid.is-list {
    grid-template-columns: 1fr;
    gap: 14px;
}

.ct-grid.is-list .ct-card {
    flex-direction: row;
}

.ct-grid.is-list .ct-card__cover {
    flex: 0 0 132px;
    margin: 12px 0 12px 12px;
    align-self: flex-start;
}

.ct-grid.is-list .ct-card__body {
    padding: 14px 18px;
}

.ct-grid.is-list .ct-card__title {
    font-size: 17px;
}

.ct-grid.is-list .ct-card__desc {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 10px 0 0;
    font-size: 13.5px;
    line-height: 1.5;
    color: var(--ct-muted);
}

/* ---------------------------------------------------------- empty + pager */

.ct-empty {
    grid-column: 1 / -1;
    text-align: center;
    padding: 56px 20px;
    background: #fff;
    border: 1px dashed #DDD9F7;
    border-radius: 18px;
}

.ct-empty__icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--ct-brand-soft);
    color: var(--ct-brand);
    font-size: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 14px;
}

.ct-empty h3 {
    margin: 0 0 6px;
    font-size: 20px;
    font-weight: 700;
}

.ct-empty p {
    margin: 0 0 18px;
    color: var(--ct-muted);
}

.ct-pager {
    display: flex;
    justify-content: center;
    margin-top: 28px;
}

.ct-pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.ct-pagination li a,
.ct-pagination li span {
    min-width: 42px;
    height: 42px;
    padding: 0 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--ct-border);
    border-radius: 12px;
    background: #fff;
    color: var(--ct-ink);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    transition: border-color .15s, color .15s, background .15s;
}

.ct-pagination li a:hover {
    border-color: var(--ct-brand);
    color: var(--ct-brand);
}

.ct-pagination li.active a,
.ct-pagination li.active span {
    background: var(--ct-brand);
    border-color: var(--ct-brand);
    color: #fff;
}

.ct-pagination li.disabled span {
    color: var(--ct-faint);
    background: var(--ct-surface-2);
}

/* ---------------------------------------------------------- tablet & phone: filter sheet */

@media (max-width: 991px) {
    .ct-layout {
        grid-template-columns: 1fr;
    }

    .ct-filter-btn {
        display: inline-flex !important;
        height: 44px;
    }

    .ct-filters {
        position: fixed;
        z-index: 1060;
        left: 0;
        right: 0;
        bottom: 0;
        top: auto;
        max-height: 85vh;
        border-radius: 22px 22px 0 0;
        border: 0;
        box-shadow: 0 -12px 40px rgba(17, 20, 45, .2);
        transform: translateY(100%);
        visibility: hidden;
        transition: transform .25s ease, visibility .25s;
    }

    .ct-filters-open .ct-filters {
        transform: none;
        visibility: visible;
    }

    .ct-filters__head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 14px 16px 10px;
        border-bottom: 1px solid var(--ct-border);
        font-size: 17px;
    }

    .ct-filters__head::before {
        content: "";
        position: absolute;
        top: 6px;
        left: 50%;
        width: 40px;
        height: 4px;
        margin-left: -20px;
        border-radius: 2px;
        background: #DADAE3;
    }

    .ct-filters__foot {
        display: flex;
        gap: 10px;
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
        border-top: 1px solid var(--ct-border);
        background: #fff;
    }

    .ct-filters__foot .ct-btn {
        flex: 1;
        height: 46px;
        padding: 0 10px;
        font-size: 13.5px;
    }

    .ct-filters__foot .ct-btn--ghost {
        flex: 0 0 auto;
    }

    .ct-backdrop {
        position: fixed;
        z-index: 1055;
        inset: 0;
        background: rgba(17, 20, 45, .45);
    }

    .ct-filters-open .ct-backdrop {
        display: block;
    }

    .ct-filters-open {
        overflow: hidden;
    }

    .ct-view {
        display: none;
    }
}

@media (max-width: 767px) {
    .ct-head h1 {
        font-size: 26px;
    }

    .ct-tabs {
        width: 100%;
    }

    .ct-tab {
        flex: 1;
        justify-content: center;
        gap: 6px;
        padding: 8px 6px;
        font-size: 13px;
    }

    .ct-tab em {
        padding: 1px 6px;
        font-size: 11px;
    }

    .ct-tab .fa-solid {
        display: none;
    }

    .ct-toolbar {
        flex-wrap: wrap;
    }

    .ct-search {
        order: -1;
        flex-basis: 100%;
    }

    .ct-filter-btn,
    .ct-sort {
        flex: 1;
    }

    .ct-sort select {
        width: 100%;
    }

    .ct-grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }

    .ct-card {
        border-radius: 14px;
    }

    .ct-card__cover {
        margin: 8px 8px 0;
        border-radius: 10px;
    }

    .ct-card__body {
        padding: 10px 10px 12px;
    }

    .ct-card__title {
        font-size: 14px;
    }

    .ct-card__meta > span:nth-child(2) {
        display: none;
    }

    .ct-card__foot .ct-btn {
        width: 100%;
    }

    .ct-card__percent {
        display: none;
    }
}
