/* Publications — liste et visionneuse PDF. Reprend les variables du thème quand elles existent. */

.pub {
    --pub-ink: var(--c-ink, #1d1d1b);
    --pub-accent: var(--c-olive, #5c6339);
    --pub-accent-dark: var(--c-olive-dark, #464b2b);
    --pub-soft: var(--c-olive-light, #e4e5da);
    --pub-card: var(--c-cream, #faf9f5);
    --pub-line: var(--c-line, #d3d0bf);
    --pub-radius: var(--radius, 10px);
    margin-block: 2rem;
}

.pub-nav {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
    margin-bottom: 2.5rem;
}

.pub-nav__link {
    padding: .4rem 1rem;
    border: 1px solid var(--pub-line);
    border-radius: 999px;
    background: var(--pub-card);
    font-size: .95rem;
    text-decoration: none;
}

.pub-nav__link:hover { border-color: var(--pub-accent); color: var(--pub-accent); }

.pub-section { margin-bottom: 3.5rem; scroll-margin-top: 6rem; }
.pub-section__title { margin: 0 0 .5rem; }
.pub-section__intro { margin: 0 0 1.25rem; }

.pub-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 1.75rem 1.25rem;
    margin: 1.25rem 0 0;
    padding: 0;
    list-style: none;
}

.pub-card { margin: 0; padding: 0; }
.pub-card::before { content: none; }

.pub-card__link {
    display: flex;
    flex-direction: column;
    gap: .6rem;
    height: 100%;
    color: inherit;
    text-decoration: none;
}

a.pub-card__link:hover { color: inherit; }

.pub-card__cover {
    display: block;
    position: relative;
    aspect-ratio: 1 / 1.414;
    overflow: hidden;
    border: 1px solid var(--pub-line);
    border-radius: calc(var(--pub-radius) * .6);
    background: #fff;
    box-shadow: 0 1px 2px rgb(0 0 0 / .06), 0 6px 16px -8px rgb(0 0 0 / .18);
    transition: transform .2s ease, box-shadow .2s ease;
}

.pub-card__cover img {
    display: block;
    width: 100%;
    height: 100%;
    max-height: none;
    margin: 0;
    object-fit: cover;
    object-position: top center;
}

.pub-card__cover--empty {
    display: grid;
    place-items: center;
    aspect-ratio: 4 / 3;
    background: var(--pub-soft);
    box-shadow: none;
}

.pub-card__icon { width: 2.75rem; height: 2.75rem; fill: var(--pub-accent); }

a.pub-card__link:hover .pub-card__cover,
a.pub-card__link:focus-visible .pub-card__cover {
    transform: translateY(-3px);
    box-shadow: 0 2px 4px rgb(0 0 0 / .08), 0 14px 28px -10px rgb(0 0 0 / .3);
}

.pub-card__body { display: flex; flex-direction: column; gap: .2rem; }
.pub-card__title { color: var(--pub-ink); font-weight: 700; line-height: 1.3; }
.pub-card__meta { font-size: .9rem; opacity: .75; }
.pub-card__desc { font-size: .9rem; }

.pub-card__action {
    align-self: flex-start;
    margin-top: auto;
    padding: .3rem .9rem;
    border-radius: 999px;
    background: var(--pub-accent);
    color: #fff;
    font-size: .9rem;
    font-weight: 600;
}

a.pub-card__link:hover .pub-card__action { background: var(--pub-accent-dark); }

.pub-card__audio { width: 100%; height: 36px; margin-top: auto; }

.pub-empty { text-align: center; }

@media (max-width: 480px) {
    .pub-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem 1rem; }
}

/* ---------- Visionneuse ---------- */

html.pdfv-open { overflow: hidden; }

.pdfv {
    --pdfv-bar: #1f2321;
    width: 100vw;
    max-width: none;
    height: 100dvh;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: #3a3f3c;
    color: #fff;
    font-family: var(--f-sans, system-ui, sans-serif);
}

.pdfv[open] { display: flex; flex-direction: column; }
.pdfv::backdrop { background: rgb(0 0 0 / .6); }

.pdfv__bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: .5rem 1rem;
    padding: .5rem max(.75rem, env(safe-area-inset-right)) .5rem max(1rem, env(safe-area-inset-left));
    background: var(--pdfv-bar);
    box-shadow: 0 1px 0 rgb(255 255 255 / .08);
}

.pdfv__title {
    flex: 1 1 16rem;
    min-width: 0;
    margin: 0;
    overflow: hidden;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.pdfv__tools { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
.pdfv__group { display: flex; align-items: center; gap: .15rem; }
.pdfv__group + .pdfv__group { padding-left: .5rem; border-left: 1px solid rgb(255 255 255 / .15); }

.pdfv__btn {
    display: inline-grid;
    place-items: center;
    min-width: 2.5rem;
    height: 2.5rem;
    padding: 0 .4rem;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #fff;
    font: inherit;
    font-size: .875rem;
    cursor: pointer;
    text-decoration: none;
}

.pdfv__btn:hover, .pdfv__btn:focus-visible { background: rgb(255 255 255 / .12); color: #fff; }
.pdfv__btn svg { width: 1.375rem; height: 1.375rem; fill: currentColor; }
.pdfv__zoom { min-width: 3.75rem; font-variant-numeric: tabular-nums; }
.pdfv__close { background: rgb(255 255 255 / .1); }

.pdfv__count {
    min-width: 4.5rem;
    font-size: .875rem;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.pdfv__stage {
    flex: 1;
    overflow: auto;
    padding: 1.25rem 1rem 3rem;
    overscroll-behavior: contain;
    outline: none;
}

.pdfv__pages { display: flex; flex-direction: column; align-items: center; gap: 1rem; min-width: min-content; }

.pdfv__page {
    flex: none;
    max-width: none;
    background: #fff;
    box-shadow: 0 4px 18px rgb(0 0 0 / .35);
}

.pdfv__page:not(.is-rendered) {
    background: #fff linear-gradient(100deg, transparent 30%, rgb(0 0 0 / .05) 50%, transparent 70%) 0 0 / 200% 100%;
    animation: pdfv-shimmer 1.4s linear infinite;
}

.pdfv__page canvas { display: block; width: 100%; height: 100%; }

.pdfv__status { margin: 3rem auto; text-align: center; }
.pdfv__status[hidden] { display: none; }
.pdfv__status a { color: #fff; font-weight: 600; }
.pdfv__status.is-error { color: #ffd6d6; }

@keyframes pdfv-shimmer { to { background-position: -200% 0; } }

@media (max-width: 640px) {
    .pdfv__bar { padding-block: .35rem; }
    .pdfv__title { flex-basis: 100%; font-size: .9rem; }
    .pdfv__tools { width: 100%; justify-content: space-between; }
    .pdfv__hide-sm, .pdfv__zoom { display: none; }
    .pdfv__tools { flex-wrap: nowrap; gap: .25rem; }
    .pdfv__group + .pdfv__group { padding-left: .25rem; }
    .pdfv__btn { min-width: 2.25rem; height: 2.25rem; padding: 0 .2rem; }
    .pdfv__count { min-width: 3.25rem; }
    .pdfv__stage { padding: .75rem .5rem 2rem; }
}

@media (prefers-reduced-motion: reduce) {
    .pub-card__cover { transition: none; }
    .pdfv__page:not(.is-rendered) { animation: none; }
}
