/**
 * Vision Jeunesse Nouvelle — Publications Repository
 *
 * A document repository, not a blog grid: filter tabs, a dense toolbar, and
 * scannable rows built for "find the PDF and get it," not for photography.
 * Everything here is scoped under .pub-repo so it cannot leak site-wide.
 */

.pub-repo {
    --pub-blue-bg: #eff6ff;   --pub-blue-fg: #1d4ed8;   --pub-blue-bd: #bfdbfe;
    --pub-indigo-bg: #eef2ff; --pub-indigo-fg: #4338ca; --pub-indigo-bd: #c7d2fe;
    --pub-teal-bg: #e6f4f1;   --pub-teal-fg: #00695c;   --pub-teal-bd: #b2dfdb;
    --pub-amber-bg: #fffbeb;  --pub-amber-fg: #b45309;  --pub-amber-bd: #fde68a;
    --pub-slate-bg: #f1f5f9;  --pub-slate-fg: #475569;  --pub-slate-bd: #e2e8f0;
    --pub-rose-bg: #fee2e2;   --pub-rose-fg: #dc2626;
    --pub-green-bg: #dcfce7;  --pub-green-fg: #16a34a;
    --pub-orange-bg: #ffedd5; --pub-orange-fg: #ea580c;
    --pub-purple-bg: #f3e8ff; --pub-purple-fg: #9333ea;
}

/* ------------------------------------------------------------- intro band */

.pub-hero {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #092047 0%, #0d47a1 50%, #00695c 100%);
    color: #fff;
}

.pub-hero__pattern {
    position: absolute;
    inset: 0;
    background-image: radial-gradient(rgba(255, 255, 255, 0.12) 1.5px, transparent 1.5px);
    background-size: 28px 28px;
    opacity: 0.6;
    pointer-events: none;
}

/* ------------------------------------------------------------------ tabs */

.pub-tabs-rail {
    /* A five-plus-tab row must never force the page to scroll sideways on a
       320px phone; it scrolls internally instead — a standard, accessible
       pattern for filter chips. */
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.pub-tabs-rail::-webkit-scrollbar {
    display: none;
}

.pub-tabs {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
    width: max-content;
    min-width: 100%;
}

.pub-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
    padding: 0.6rem 1.05rem;
    border: 1px solid #e2e8f0;
    border-radius: 100px;
    background: #f8fafc;
    color: #475569;
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.pub-tab:hover {
    background: #eef2f7;
    color: #1e293b;
    transform: translateY(-1px);
}

.pub-tab.is-active {
    background: #092047;
    border-color: #092047;
    color: #fff;
    box-shadow: 0 4px 14px rgba(9, 32, 71, 0.25);
}

.pub-tab.is-active:hover {
    background: #0d2a5c;
    color: #fff;
}

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

.pub-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.pub-count {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #475569;
    white-space: nowrap;
}

.pub-count strong {
    color: #0f172a;
    font-size: 0.9rem;
}

.pub-toolbar-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.pub-search {
    position: relative;
    width: 200px;
}

.pub-search input {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2.1rem;
    border: 1px solid #e2e8f0;
    border-radius: 100px;
    background: #f8fafc;
    font-size: 0.8125rem;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.pub-search input:focus {
    outline: none;
    border-color: #0d47a1;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(13, 71, 161, 0.12);
}

.pub-search i {
    position: absolute;
    left: 0.8rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 0.8rem;
    pointer-events: none;
}

.pub-select {
    padding: 0.5rem 2rem 0.5rem 0.9rem;
    border: 1px solid #e2e8f0;
    border-radius: 100px;
    background: #f8fafc;
    color: #334155;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
}

.pub-select:focus {
    outline: none;
    border-color: #0d47a1;
}

/* Grid / list view switch */
.pub-view-switch {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    background: #f8fafc;
}

.pub-view-btn {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: #94a3b8;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.pub-view-btn:hover {
    color: #475569;
}

.pub-view-btn.is-active {
    background: #fff;
    color: #0d47a1;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
}

/* ------------------------------------------------------------------- grid */

.pub-grid {
    display: grid;
    /* minmax(0, 1fr), not a bare 1fr: a bare 1fr track's minimum size is
       content-based, so a wide card would force the track — and the page —
       wider instead of shrinking. This is what caused overflow at 320px. */
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 1.25rem;
}

@media (max-width: 899.98px) {
    .pub-grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ------------------------------------------------------------------- card */

.pub-card {
    display: flex;
    gap: 1rem;
    min-width: 0;
    padding: 1.25rem;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background: #fff;
    transition: box-shadow 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
}

.pub-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.08);
    transform: translateY(-2px);
}

.pub-card.is-featured {
    border-color: var(--pub-amber-bd);
    background: linear-gradient(180deg, #fffdf5 0%, #fff 90px);
}

.pub-card__icon {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    border-radius: 12px;
    font-size: 1.35rem;
}

.pub-card__body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.pub-card__top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.pub-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: 100px;
    border: 1px solid transparent;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.pub-badge--blue   { background: var(--pub-blue-bg);   color: var(--pub-blue-fg);   border-color: var(--pub-blue-bd); }
.pub-badge--indigo { background: var(--pub-indigo-bg); color: var(--pub-indigo-fg); border-color: var(--pub-indigo-bd); }
.pub-badge--teal    { background: var(--pub-teal-bg);   color: var(--pub-teal-fg);   border-color: var(--pub-teal-bd); }
.pub-badge--amber  { background: var(--pub-amber-bg);  color: var(--pub-amber-fg);  border-color: var(--pub-amber-bd); }
.pub-badge--slate  { background: var(--pub-slate-bg);  color: var(--pub-slate-fg);  border-color: var(--pub-slate-bd); }

.pub-card__icon--rose   { background: var(--pub-rose-bg);   color: var(--pub-rose-fg); }
.pub-card__icon--blue   { background: var(--pub-blue-bg);   color: var(--pub-blue-fg); }
.pub-card__icon--green  { background: var(--pub-green-bg);  color: var(--pub-green-fg); }
.pub-card__icon--orange { background: var(--pub-orange-bg); color: var(--pub-orange-fg); }
.pub-card__icon--purple { background: var(--pub-purple-bg); color: var(--pub-purple-fg); }
.pub-card__icon--slate  { background: var(--pub-slate-bg);  color: var(--pub-slate-fg); }

.pub-card__date {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    flex-shrink: 0;
    font-size: 0.75rem;
    color: #94a3b8;
    white-space: nowrap;
    padding-top: 0.15rem;
}

.pub-card__title {
    margin: 0 0 0.3rem;
    font-family: 'Poppins', sans-serif;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.35;
    color: #0f172a;
}

.pub-card__title a {
    color: inherit;
    text-decoration: none;
}

.pub-card__title a:hover {
    color: #0d47a1;
}

.pub-card__desc {
    margin: 0 0 0.85rem;
    font-size: 0.8375rem;
    line-height: 1.55;
    color: #64748b;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pub-card__foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem 0.75rem;
    min-width: 0;
    margin-top: auto;
    padding-top: 0.85rem;
    border-top: 1px solid #f1f5f9;
}

.pub-card__meta {
    min-width: 0;
    font-size: 0.75rem;
    font-weight: 600;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pub-card__actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.pub-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.9rem;
    border-radius: 8px;
    border: 1px solid transparent;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.pub-btn--ghost {
    background: #f8fafc;
    border-color: #e2e8f0;
    color: #334155;
}

.pub-btn--ghost:hover {
    background: #eef2f7;
    border-color: #cbd5e1;
    color: #0f172a;
}

.pub-btn--solid {
    background: #0d47a1;
    color: #fff;
}

.pub-btn--solid:hover {
    background: #0a3980;
    color: #fff;
    transform: translateY(-1px);
}

.pub-btn:active {
    transform: translateY(0);
}

/* Featured star */
.pub-card__star {
    position: absolute;
    top: -8px;
    right: -8px;
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #ffc107;
    color: #78350f;
    font-size: 0.7rem;
    box-shadow: 0 3px 8px rgba(180, 130, 0, 0.35);
}

.pub-card__icon-wrap {
    position: relative;
    flex-shrink: 0;
}

/* -------------------------------------------------------------- list view */

.pub-repo[data-view="list"] .pub-grid {
    grid-template-columns: 1fr;
    gap: 0.6rem;
}

.pub-repo[data-view="list"] .pub-card {
    align-items: center;
    padding: 0.75rem 1.1rem;
}

.pub-repo[data-view="list"] .pub-card__icon {
    width: 38px;
    height: 38px;
    font-size: 1rem;
    border-radius: 9px;
}

.pub-repo[data-view="list"] .pub-card__top {
    margin-bottom: 0.15rem;
}

.pub-repo[data-view="list"] .pub-card__desc {
    display: none;
}

.pub-repo[data-view="list"] .pub-card__title {
    font-size: 0.9rem;
}

.pub-repo[data-view="list"] .pub-card__foot {
    margin-top: 0.35rem;
    padding-top: 0;
    border-top: 0;
}

@media (min-width: 900px) {
    /* Wide screens: collapse each row onto a single line for real density */
    .pub-repo[data-view="list"] .pub-card {
        flex-wrap: nowrap;
    }
    .pub-repo[data-view="list"] .pub-card__body {
        flex-direction: row;
        align-items: center;
        gap: 1rem;
    }
    .pub-repo[data-view="list"] .pub-card__top {
        flex-direction: column-reverse;
        align-items: flex-start;
        gap: 0.2rem;
        flex-shrink: 0;
        width: 128px;
    }
    .pub-repo[data-view="list"] .pub-card__main {
        flex: 1;
        min-width: 0;
    }
    .pub-repo[data-view="list"] .pub-card__title {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        margin-bottom: 0;
    }
    .pub-repo[data-view="list"] .pub-card__foot {
        flex-shrink: 0;
        width: auto;
    }
}

/* Default: this attribute-driven presentation only kicks in once JS has
   confirmed a view mode; markup always starts as grid so no-JS is fine. */

/* ---------------------------------------------------------------- states */

.pub-empty {
    text-align: center;
    padding: 4rem 1.5rem;
    border: 1px dashed #cbd5e1;
    border-radius: 16px;
    background: #f8fafc;
}

/* -------------------------------------------------------------- pagination */

.pub-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.pub-page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 0.6rem;
    border: 1px solid #e2e8f0;
    border-radius: 9px;
    background: #fff;
    color: #334155;
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.pub-page-link:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
    color: #0f172a;
}

.pub-page-link.is-active {
    background: #092047;
    border-color: #092047;
    color: #fff;
}

.pub-page-link.is-disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* ------------------------------------------------------------------ focus */

.pub-repo a:focus-visible,
.pub-repo button:focus-visible,
.pub-repo input:focus-visible,
.pub-repo select:focus-visible {
    outline: 2px solid #0d47a1;
    outline-offset: 2px;
    border-radius: 4px;
}

/* -------------------------------------------------------------- responsive */

@media (max-width: 575.98px) {
    .pub-toolbar {
        align-items: stretch;
    }
    .pub-search {
        width: 100%;
    }
    .pub-toolbar-controls {
        width: 100%;
    }
    .pub-card {
        padding: 1rem;
    }
    .pub-card__actions {
        flex-shrink: 0;
    }
    .pub-btn span {
        display: none;
    }
    .pub-btn {
        padding: 0.5rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .pub-card,
    .pub-btn,
    .pub-tab {
        transition: none;
    }
    .pub-card:hover,
    .pub-btn--solid:hover {
        transform: none;
    }
}
