/**
 * NX Portfolio — styles front.
 *
 * Règles d'alignement NON NÉGOCIABLES (spec §4.4) :
 *  - media : aspect-ratio fixe + object-fit cover → même boîte pour toute image,
 *    espace réservé avant chargement → 0 CLS ;
 *  - titre : line-clamp 2 + min-height 2 lignes → aucun décalage entre cartes.
 * Effets CSS-only, désactivés sous prefers-reduced-motion.
 */

/* ── Grille ─────────────────────────────────────────────────────────── */
.nxp-pfg { --nxp-pfg-gap: 20px; --nxp-pfg-radius: 14px; }

.nxp-pfg__grid {
    display: grid;
    gap: var(--nxp-pfg-gap);
    list-style: none;
    margin: 0;
    padding: 0;
}
.nxp-pfg--cols-2 .nxp-pfg__grid { grid-template-columns: repeat(2, 1fr); }
.nxp-pfg--cols-3 .nxp-pfg__grid { grid-template-columns: repeat(3, 1fr); }
.nxp-pfg--cols-4 .nxp-pfg__grid { grid-template-columns: repeat(4, 1fr); }

@media (max-width: 900px) {
    .nxp-pfg--cols-3 .nxp-pfg__grid,
    .nxp-pfg--cols-4 .nxp-pfg__grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
    .nxp-pfg__grid { grid-template-columns: 1fr !important; }
}

/* « À la une » : la 1re carte s'étale sur 2 colonnes (carte hero).
   Cible .is-first-visible (posée par view.js sur le 1er item RÉELLEMENT
   visible) et non :first-child, qui resterait sur un item filtré/caché. */
@media (min-width: 601px) {
    .nxp-pfg--featured .nxp-pfg__item.is-first-visible { grid-column: span 2; }
}

.nxp-pfg__item { margin: 0; }
.nxp-pfg__item[hidden] { display: none; }

/* ── Carte ──────────────────────────────────────────────────────────── */
.nxp-pfg__card {
    height: 100%;
    border-radius: var(--nxp-pfg-radius);
    overflow: hidden;
    background: var(--nxp-pfg-card-bg, #f6f7f7);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: box-shadow 0.28s ease, transform 0.28s ease;
}
.nxp-pfg__card:hover,
.nxp-pfg__card:focus-within {
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
    transform: translateY(-3px);
}
/* Style overlay : pas de fond de carte (l'image EST la carte). */
.nxp-pfg--overlay .nxp-pfg__card { background: transparent; }

/* Sans ombre (thèmes flat/angulaires) : lift conservé, ombre coupée. */
.nxp-pfg--flat .nxp-pfg__card,
.nxp-pfg--flat .nxp-pfg__card:hover,
.nxp-pfg--flat .nxp-pfg__card:focus-within { box-shadow: none; }

.nxp-pfg__link {
    display: flex;
    flex-direction: column;
    height: 100%;
    text-decoration: none;
    color: inherit;
}
.nxp-pfg__link:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 3px;
    border-radius: var(--nxp-pfg-radius);
}

/* ── Media : LA règle anti-décalage image ───────────────────────────── */
.nxp-pfg__media {
    position: relative;
    display: block;
    width: 100%;
    overflow: hidden;
    background: #e8eaed;
}
.nxp-pfg--ratio-4-3  .nxp-pfg__media { aspect-ratio: 4 / 3; }
.nxp-pfg--ratio-16-10 .nxp-pfg__media { aspect-ratio: 16 / 10; }
.nxp-pfg--ratio-1-1  .nxp-pfg__media { aspect-ratio: 1 / 1; }
.nxp-pfg--ratio-3-4  .nxp-pfg__media { aspect-ratio: 3 / 4; }

.nxp-pfg__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.35s ease;
}
.nxp-pfg__card:hover .nxp-pfg__img,
.nxp-pfg__card:focus-within .nxp-pfg__img { transform: scale(1.04); }

/* Repli sans image mise en avant : jamais de trou. */
.nxp-pfg__placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    font-weight: 700;
    color: rgba(0, 0, 0, 0.22);
    background: linear-gradient(135deg, #e8eaed, #d4d8dd);
}

/* ── Badge catégorie ────────────────────────────────────────────────── */
.nxp-pfg__badge {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2;
    padding: 4px 12px;
    /* Suit l'arrondi global : 0 → angles droits, sinon pilule. */
    border-radius: min(999px, calc(var(--nxp-pfg-radius, 14px) * 999));
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: #1d2327;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(4px);
}

/* ── Style « Carte » : zone texte normée ────────────────────────────── */
.nxp-pfg__body {
    display: block;
    padding: 16px 18px 18px;
    flex: 1 1 auto;
}
/* LA règle anti-décalage titre : 2 lignes max, hauteur toujours identique. */
.nxp-pfg__title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.35;
    min-height: calc(2 * 1.35em);
}
.nxp-pfg__excerpt {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-top: 8px;
    font-size: 0.88rem;
    line-height: 1.5;
    min-height: calc(2 * 1.5em);
    color: rgba(0, 0, 0, 0.65);
}

/* ── Style « Overlay » : titre sur l'image ──────────────────────────── */
.nxp-pfg__overlay {
    position: absolute;
    inset: auto 0 0 0;
    z-index: 1;
    padding: 40px 18px 16px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.78), rgba(0, 0, 0, 0.35) 60%, transparent);
    color: #fff;
}
.nxp-pfg--overlay .nxp-pfg__title { color: #fff; min-height: 0; }

/* Mode « au survol » : masqué par défaut, révélé au hover / focus. */
.nxp-pfg--overlay-hover .nxp-pfg__overlay {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.28s ease, transform 0.28s ease;
}
.nxp-pfg--overlay-hover .nxp-pfg__card:hover .nxp-pfg__overlay,
.nxp-pfg--overlay-hover .nxp-pfg__card:focus-within .nxp-pfg__overlay {
    opacity: 1;
    transform: translateY(0);
}
/* Tactile (pas de survol possible) : overlay toujours visible. */
@media (hover: none) {
    .nxp-pfg--overlay-hover .nxp-pfg__overlay { opacity: 1; transform: none; }
}

/* ── Barre de filtres (pills) ───────────────────────────────────────── */
.nxp-pfg__filters {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 22px;
}
.nxp-pfg__pill {
    appearance: none;
    border: 1px solid rgba(0, 0, 0, 0.16);
    background: transparent;
    color: inherit;
    padding: 7px 16px;
    /* Suit l'arrondi global : 0 → angles droits, sinon pilule. */
    border-radius: min(999px, calc(var(--nxp-pfg-radius, 14px) * 999));
    font-size: 0.88rem;
    font-weight: 500;
    line-height: 1.2;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}
.nxp-pfg__pill:hover { border-color: currentColor; }
.nxp-pfg__pill:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; }
.nxp-pfg__pill.is-active {
    background: var(--nxp-pfg-pill-active, #1d2327);
    border-color: var(--nxp-pfg-pill-active, #1d2327);
    color: #fff;
}
.nxp-pfg__pill-count { opacity: 0.6; font-weight: 400; margin-left: 2px; }

/* Annonce lecteur d'écran (aria-live) — masquée visuellement. */
.nxp-pfg__status {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* ── Animations (apparition au scroll + filtrage) ───────────────────── */
.nxp-pfg[data-animated="true"] .nxp-pfg__item {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.45s ease var(--nxp-pfg-delay, 0ms),
                transform 0.45s ease var(--nxp-pfg-delay, 0ms);
}
.nxp-pfg[data-animated="true"] .nxp-pfg__item.is-visible {
    opacity: 1;
    transform: none;
}
/* Filtrage : sortie en fondu (le retrait du DOM visuel se fait après). */
.nxp-pfg .nxp-pfg__item.is-filtering-out {
    opacity: 0 !important;
    transform: scale(0.96) !important;
    transition: opacity 0.18s ease, transform 0.18s ease !important;
}

@media (prefers-reduced-motion: reduce) {
    .nxp-pfg[data-animated="true"] .nxp-pfg__item,
    .nxp-pfg .nxp-pfg__item.is-filtering-out,
    .nxp-pfg__img,
    .nxp-pfg__card,
    .nxp-pfg--overlay-hover .nxp-pfg__overlay {
        transition: none !important;
        transform: none !important;
        opacity: 1 !important;
    }
    .nxp-pfg--overlay-hover .nxp-pfg__overlay { opacity: 1; }
}

/* Notice éditeur (CPT absent / vide) */
.nxp-pfg-notice {
    padding: 12px 16px;
    background: #fcf9e8;
    border-left: 4px solid #dba617;
}

.nexxis-block-portfolio .nxp-pfg__grid {
    & .nxp-pfg__card {
      border-radius: var(--border-radius-m);
      position: relative;
      & .nxp-pfg__media{
        display: flex;
        align-items: flex-end;
      }
      & > a {
        position: absolute;
        width: 100%;
        height: 100%;
        top: 0px;
        left: 0px;
        background: linear-gradient(0deg, rgba(17, 19, 21, 0.94) 0%, rgba(17, 19, 21, 0.6) 34%, rgba(17, 19, 21, 0) 66%);
        inset: 0;
        z-index: 2;
      }
      & .nxp-pfg__overlay{
        padding: 28px 30px;
        transform: none;
        gap: 12px;
        position: relative;
        z-index: 2;
        pointer-events: none;
        background: transparent;
        & .nexxis-subtitle{
          color: var(--white);
          font-size: 11px;
          gap: 8px;
          &::before{
            width: 8px;
            height: 8px;
          }
        }
        & .nxp-pfg__title{
          font-size: 26px;
          font-family: var(--font-montserrat);
        }
      }
    }
    & .nxp-pfg__card.nexxis-custom-portfolio img{
      transition: transform 0.35s ease !important;
    }
    & .nxp-pfg__card.nexxis-custom-portfolio:hover img{
      transform: scale(1.1) !important;
      transition: transform 0.35s ease !important;
    }
  }

@media (max-width: 768px){
    .nxp-pfg__overlay{
        padding: 15px;
        & .nxp-pfg__title{
            font-size: 18px !important;
            display: inline;
        }
    }
}