/* ==========================================================================
   PAGE CATALOGUES (vue/catalogues.php)
   S'appuie sur les variables et composants de css/chavigny.css
   ========================================================================== */

.ct {
    background: var(--ch-white);
}

/* --------------------------------------------------------------------------
   En-tête
   -------------------------------------------------------------------------- */
.ct-head {
    padding: 22px 0 30px;
    border-bottom: 1px solid var(--ch-border);
    background: var(--ch-grey-light);
}

.ct-breadcrumb ol {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin: 0 0 18px;
    padding: 0;
    list-style: none;
    font-size: .85rem;
}

.ct-breadcrumb li {
    display: inline-flex;
    align-items: center;
    color: var(--ch-grey-dark);
}

.ct-breadcrumb li + li::before {
    content: "";
    width: 6px;
    height: 6px;
    margin: 0 12px;
    border-top: 1.5px solid var(--ch-grey);
    border-right: 1.5px solid var(--ch-grey);
    transform: rotate(45deg);
}

.ct-breadcrumb a {
    color: var(--ch-grey-dark);
    text-decoration: none;
}

.ct-breadcrumb a:hover {
    color: var(--ch-red);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.ct-breadcrumb [aria-current] {
    color: var(--ch-text);
    font-weight: 700;
}

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

.ct-kicker {
    margin: 0 0 4px;
    color: var(--ch-red);
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.ct-title {
    margin: 0;
    color: var(--ch-text);
    font-family: var(--ch-font);
    font-size: clamp(1.6rem, 1.2rem + 1.6vw, 2.4rem);
    font-weight: 700;
    line-height: 1.15;
}

.ct-subtitle {
    max-width: 620px;
    margin: 10px 0 0;
    color: var(--ch-grey-dark);
    font-size: 1rem;
    line-height: 1.55;
}

.ct-count {
    margin: 0;
    padding: 8px 16px;
    border-radius: var(--ch-radius-pill);
    background: var(--ch-white);
    color: var(--ch-grey-dark);
    font-size: .92rem;
}

.ct-count strong {
    color: var(--ch-red);
}

.ct-body {
    padding-top: 32px;
    padding-bottom: 72px;
}

/* --------------------------------------------------------------------------
   Recherche et filtres
   -------------------------------------------------------------------------- */
.ct-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px 20px;
    margin-bottom: 28px;
}

.ct-search {
    position: relative;
    flex: 0 1 380px;
}

.ct-search > i {
    position: absolute;
    top: 50%;
    left: 18px;
    color: var(--ch-grey);
    transform: translateY(-50%);
    pointer-events: none;
}

.ct-search-input {
    width: 100%;
    height: 46px;
    padding: 0 18px 0 46px;
    border: 1.5px solid var(--ch-border);
    border-radius: var(--ch-radius-pill);
    background: var(--ch-white);
    color: var(--ch-text);
    font-family: var(--ch-font);
    font-size: .95rem;
    transition: border-color .2s var(--ch-ease), box-shadow .2s var(--ch-ease);
}

.ct-search-input::placeholder {
    color: var(--ch-grey);
}

.ct-search-input:focus {
    outline: none;
    border-color: var(--ch-red);
    box-shadow: 0 0 0 4px rgba(208, 52, 58, .12);
}

.ct-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.ct-filter {
    min-height: 38px;
    padding: 0 16px;
    border: 1px solid var(--ch-border);
    border-radius: var(--ch-radius-pill);
    background: var(--ch-white);
    color: var(--ch-grey-dark);
    font-family: var(--ch-font);
    font-size: .88rem;
    cursor: pointer;
    transition: border-color .15s var(--ch-ease), color .15s var(--ch-ease), background-color .15s var(--ch-ease);
}

.ct-filter:hover {
    border-color: var(--ch-red);
    color: var(--ch-red);
}

.ct-filter.is-active {
    border-color: var(--ch-red);
    background: var(--ch-red);
    color: var(--ch-white);
    font-weight: 700;
}

.ct-results {
    margin: 0 0 0 auto;
    color: var(--ch-grey-dark);
    font-size: .92rem;
}

.ct-results strong {
    color: var(--ch-text);
}

/* --------------------------------------------------------------------------
   Couverture (commune à la une / grille)
   -------------------------------------------------------------------------- */
.ct-cover,
.ct-featured-cover {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 3 / 4;
    padding: 0;
    border: 0;
    border-radius: var(--ch-radius-sm);
    background: var(--ch-grey-light);
    overflow: hidden;
    cursor: zoom-in;
}

.ct-cover img,
.ct-featured-cover img {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
    transition: transform .4s var(--ch-ease);
}

.ct-cover-fallback {
    color: var(--ch-grey);
    font-size: 3.2rem;
}

.ct-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2;
    padding: 4px 10px;
    border-radius: var(--ch-radius-pill);
    background: var(--ch-red);
    color: var(--ch-white);
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
}

.ct-cover-hover {
    position: absolute;
    inset: auto 0 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px;
    background: linear-gradient(0deg, rgba(20, 20, 22, .75), rgba(20, 20, 22, 0));
    color: var(--ch-white);
    font-family: var(--ch-font);
    font-size: .9rem;
    font-weight: 700;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity .25s var(--ch-ease), transform .25s var(--ch-ease);
}

.ct-cover:hover img,
.ct-cover:focus-visible img,
.ct-featured-cover:hover img {
    transform: scale(1.04);
}

.ct-cover:hover .ct-cover-hover,
.ct-cover:focus-visible .ct-cover-hover {
    opacity: 1;
    transform: none;
}

/* --------------------------------------------------------------------------
   Catalogue à la une
   -------------------------------------------------------------------------- */
.ct-featured {
    display: grid;
    grid-template-columns: minmax(0, 260px) minmax(0, 1fr);
    align-items: center;
    gap: 40px;
    margin-bottom: 40px;
    padding: 28px;
    border-radius: var(--ch-radius-lg);
    background: var(--ch-grey-light);
}

.ct-featured-cover {
    box-shadow: 0 16px 34px rgba(0, 0, 0, .18);
}

.ct-featured-kicker {
    margin: 0 0 8px;
    color: var(--ch-red);
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.ct-featured-title {
    margin: 0;
    color: var(--ch-text);
    font-family: var(--ch-font);
    font-size: clamp(1.4rem, 1.1rem + 1vw, 2rem);
    font-weight: 700;
    line-height: 1.2;
}

.ct-featured-desc {
    max-width: 620px;
    margin: 12px 0 0;
    color: var(--ch-grey-dark);
    font-size: 1rem;
    line-height: 1.6;
}

.ct-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    margin: 16px 0 0;
    padding: 0;
    list-style: none;
    color: var(--ch-grey-dark);
    font-size: .88rem;
}

.ct-meta i {
    color: var(--ch-red);
}

.ct-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 24px;
}

.ct-actions .ch-btn-outline {
    background: transparent;
}

/* Hors recherche : le catalogue à la une n'est pas répété dans la grille */
.ct.has-featured:not(.is-filtering) .ct-item.is-featured {
    display: none;
}

.ct.is-filtering .ct-featured {
    display: none;
}

/* --------------------------------------------------------------------------
   Grille
   -------------------------------------------------------------------------- */
.ct-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr));
    gap: 28px 24px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.ct-grid[hidden],
.ct-item[hidden] {
    display: none;
}

.ct-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 14px;
    border: 1px solid var(--ch-border);
    border-radius: var(--ch-radius);
    background: var(--ch-white);
    transition: box-shadow .25s var(--ch-ease), border-color .25s var(--ch-ease), transform .25s var(--ch-ease);
}

.ct-card:hover,
.ct-card:focus-within {
    border-color: transparent;
    box-shadow: var(--ch-shadow-lg);
    transform: translateY(-3px);
}

.ct-card-body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 6px;
    padding: 14px 2px 0;
}

.ct-card-category {
    margin: 0;
    color: var(--ch-red);
    font-size: .74rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
}

.ct-card-title {
    margin: 0;
    color: var(--ch-text);
    font-family: var(--ch-font);
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
}

.ct-card-desc {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    margin: 0;
    overflow: hidden;
    color: var(--ch-grey-dark);
    font-size: .86rem;
    line-height: 1.5;
}

.ct-card-date {
    margin: 2px 0 0;
    color: var(--ch-grey);
    font-size: .8rem;
}

.ct-card-actions {
    display: flex;
    gap: 8px;
    margin-top: auto;
    padding-top: 14px;
}

.ct-open {
    flex: 1 1 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 40px;
    padding: 0 16px;
    border-radius: var(--ch-radius-pill);
    background: var(--ch-red);
    color: var(--ch-white);
    font-size: .88rem;
    font-weight: 700;
    letter-spacing: .02em;
    text-decoration: none;
    text-transform: uppercase;
    transition: background-color .2s var(--ch-ease), box-shadow .2s var(--ch-ease);
}

.ct-open:hover,
.ct-open:focus-visible {
    background: var(--ch-red-dark);
    color: var(--ch-white);
    box-shadow: 0 6px 14px rgba(208, 52, 58, .25);
}

.ct-download {
    flex: 0 0 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 1.5px solid var(--ch-border);
    border-radius: 50%;
    color: var(--ch-grey-dark);
    font-size: 1rem;
    text-decoration: none;
    transition: border-color .2s var(--ch-ease), color .2s var(--ch-ease);
}

.ct-download:hover,
.ct-download:focus-visible {
    border-color: var(--ch-red);
    color: var(--ch-red);
}

/* --------------------------------------------------------------------------
   États vides
   -------------------------------------------------------------------------- */
.ct-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 56px 24px;
    border: 1.5px dashed var(--ch-border);
    border-radius: var(--ch-radius-lg);
    color: var(--ch-grey-dark);
    text-align: center;
}

.ct-empty[hidden] {
    display: none;
}

.ct-empty-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 68px;
    height: 68px;
    margin-bottom: 10px;
    border-radius: 50%;
    background: var(--ch-grey-light);
    color: var(--ch-grey);
    font-size: 1.8rem;
}

.ct-empty p {
    max-width: 520px;
    margin: 0;
}

.ct-empty-title {
    color: var(--ch-text);
    font-size: 1.1rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.ct-empty .ch-btn {
    margin-top: 16px;
}

/* --------------------------------------------------------------------------
   Liseuse PDF (dialog)
   -------------------------------------------------------------------------- */
.ct-viewer {
    width: min(1100px, calc(100vw - 48px));
    height: calc(100vh - 48px);
    max-width: none;
    max-height: none;
    padding: 0;
    border: 0;
    border-radius: var(--ch-radius);
    background: var(--ch-white);
    box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
    overflow: hidden;
}

.ct-viewer[open] {
    display: flex;
    flex-direction: column;
}

.ct-viewer::backdrop {
    background: rgba(20, 20, 22, .7);
}

.ct-viewer-head {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 12px 10px 22px;
    border-bottom: 1px solid var(--ch-grey-light);
}

.ct-viewer-title {
    flex: 1 1 auto;
    min-width: 0;
    margin: 0;
    overflow: hidden;
    color: var(--ch-text);
    font-size: 1.02rem;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ct-viewer-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ct-viewer-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 38px;
    padding: 0 14px;
    border: 1.5px solid var(--ch-border);
    border-radius: var(--ch-radius-pill);
    color: var(--ch-grey-dark);
    font-size: .86rem;
    font-weight: 700;
    text-decoration: none;
    transition: border-color .15s var(--ch-ease), color .15s var(--ch-ease);
}

.ct-viewer-btn:hover,
.ct-viewer-btn:focus-visible {
    border-color: var(--ch-red);
    color: var(--ch-red);
}

.ct-viewer-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: var(--ch-red);
    color: var(--ch-white);
    font-size: 1.05rem;
    cursor: pointer;
    transition: background-color .15s var(--ch-ease);
}

.ct-viewer-close:hover {
    background: var(--ch-red-dark);
}

.ct-viewer-frame {
    position: relative;
    flex: 1 1 auto;
    background: var(--ch-grey-light);
}

.ct-viewer-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 0;
    color: var(--ch-grey-dark);
    font-size: .95rem;
}

.ct-viewer-frame iframe {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    border: 0;
    background: transparent;
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1023px) {
    .ct-featured {
        grid-template-columns: minmax(0, 200px) minmax(0, 1fr);
        gap: 28px;
        padding: 22px;
    }
}

@media (max-width: 640px) {
    .ct-head {
        padding: 16px 0 22px;
    }

    .ct-body {
        padding-top: 22px;
        padding-bottom: 48px;
    }

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

    .ct-search-input {
        font-size: 16px; /* évite le zoom automatique iOS */
    }

    .ct-filters {
        flex-wrap: nowrap;
        margin: 0 calc(var(--ch-gutter) * -1);
        padding: 2px var(--ch-gutter);
        overflow-x: auto;
        scrollbar-width: none;
    }

    .ct-filters::-webkit-scrollbar {
        display: none;
    }

    .ct-filter {
        flex: 0 0 auto;
    }

    .ct-results {
        margin-left: 0;
    }

    .ct-featured {
        grid-template-columns: 1fr;
        gap: 20px;
        padding: 18px;
    }

    .ct-featured-cover {
        max-width: 200px;
        margin: 0 auto;
    }

    .ct-actions .ch-btn {
        flex: 1 1 100%;
    }

    .ct-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 16px 12px;
    }

    .ct-card {
        padding: 10px;
    }

    .ct-card-title {
        font-size: .92rem;
    }

    .ct-card-desc {
        -webkit-line-clamp: 2;
    }

    .ct-open {
        padding: 0 10px;
        font-size: .8rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .ct-card,
    .ct-cover img,
    .ct-featured-cover img,
    .ct-cover-hover {
        transition: none;
    }
}

/* Catalogue en ligne (url_catalogue) : pastille sur la couverture */
.ct-badge-online {
    top: auto;
    bottom: 10px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(42, 43, 46, .85);
}

a.ct-cover,
a.ct-featured-cover {
    text-decoration: none;
}

/* Rond « lien externe » des catalogues en ligne (même gabarit que le téléchargement) */
.ct-external {
    font-size: .9rem;
}
