/* mod_threejs_oinf — grid.css — Three.js Grid builder element (ported from TDM) */

.oinf-grid-wrap {
    width: 100%;
    overflow: visible;
}

/* let items translate from the centre without being clipped */
.oinf-grid-cells {
    overflow: visible !important;
}

.oinf-grid-card-img {
    width: 100%;
    overflow: hidden;
    line-height: 0;
}
.oinf-grid-card-img img,
.oinf-grid-card-img video,
.oinf-grid-card-img iframe {
    display: block;
    width: 100%;
}
.oinf-grid-card-img img {
    height: auto;
    object-fit: cover;
}
.uk-text-center .oinf-grid-card-img img { margin-left: auto; margin-right: auto; }
.uk-text-right  .oinf-grid-card-img img { margin-left: auto; }

/* Panel link overlay — invisible full-card click target */
.oinf-grid-linked { position: relative; }
.oinf-grid-card-link-overlay { position: absolute; inset: 0; z-index: 1; }
.oinf-grid-linked .uk-card-title a,
.oinf-grid-linked .oinf-grid-card-img a { position: relative; z-index: 2; }

/* Center columns — last row aligns to centre when incomplete */
.oinf-grid-centered .oinf-grid-cells { justify-content: center; }

/* Match height — all cards in a row stretch to the same height */
.oinf-grid-cells.oinf-grid-match > .oinf-grid-item { display: flex; }
.oinf-grid-cells.oinf-grid-match .oinf-grid-card {
    display: flex;
    flex-direction: column;
    width: 100%;
}
.oinf-grid-cells.oinf-grid-match .oinf-grid-card-content { flex: 1; min-height: 0; }

.oinf-grid-card-content {
    line-height: 1.45;
}

/* Row Gap — overrides the UIkit row margin independently of the column gap */
.oinf-grid-cells.oinf-rowgap-collapse > .uk-grid-margin { margin-top: 0 !important; }
.oinf-grid-cells.oinf-rowgap-small    > .uk-grid-margin { margin-top: 15px !important; }
.oinf-grid-cells.oinf-rowgap-medium   > .uk-grid-margin { margin-top: 30px !important; }
.oinf-grid-cells.oinf-rowgap-large    > .uk-grid-margin { margin-top: 70px !important; }

/* YouTube facade — thumbnail + play button, click to load the player */
.oinf-grid-video {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    cursor: pointer;
    background: #000;
    overflow: hidden;
}
.oinf-grid-video img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.oinf-grid-play {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 68px;
    height: 48px;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.55);
    border-radius: 12px;
    transition: background 0.2s ease;
}
.oinf-grid-play::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-40%, -50%);
    border-style: solid;
    border-width: 11px 0 11px 18px;
    border-color: transparent transparent transparent #fff;
}
.oinf-grid-video:hover .oinf-grid-play { background: #f00; }

/* ── Titre en surimpression (option title_overlay) ──────────────────────────
   Le conteneur d'image devient le repere de positionnement : sans position:relative
   ici, le titre se calerait sur le premier ancetre positionne, souvent la carte
   entiere voire la section. */
.oinf-grid-card-img { position: relative; }

.oinf-grid-img-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 10px;
    /* le titre ne doit pas intercepter le clic destine a l'image/au lien */
    pointer-events: none;
    /* voile leger : un titre clair sur une photo claire serait illisible */
    background: rgba(0, 0, 0, .28);
}

/* ── Icone YouTube en surimpression (option play_icon) ──────────────────────
   ATTENTION : .oinf-grid-play est DEJA pris — c est le bouton de lecture de la
   facade YouTube (le rectangle rouge). D ou le nom .oinf-grid-ytmark ici.

   L icone et le titre partagent UN SEUL calque, empiles en colonne : deux calques
   centres separement se superposeraient. L icone passe donc au-dessus du titre
   quand les deux sont actifs, et se centre seule quand le titre est absent. */
.oinf-grid-img-overlay {
    flex-direction: column;
    gap: 10px;
}

/* Pas de titre a habiller = pas de voile : la photo reste franche. */
.oinf-grid-img-overlay--bare {
    background: none;
}

.oinf-grid-ytmark {
    flex: 0 0 auto;
    display: block;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, .65));
    opacity: .92;
    transition: opacity .3s ease, transform .3s ease;
}
.oinf-grid-card:hover .oinf-grid-ytmark {
    opacity: 1;
    transform: scale(1.1);
}

@media (prefers-reduced-motion: reduce) {
    .oinf-grid-ytmark { transition: none; }
}

.oinf-grid-img-overlay > * {
    margin: 0;
    color: #fff;
    text-shadow: 0 1px 3px rgba(0, 0, 0, .55);
}

/* ── Lightbox du grid (option lightbox) ─────────────────────────────────────
   Classes propres au grid : l element doit rester autonome. Le shapes utilise
   encore un prefixe .helix-* herite d un element qui n existe plus. */
.oinf-grid-lb-overlay {
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(0, 0, 0, .92);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
}
.oinf-grid-lb-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

.oinf-grid-lb-img {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
    display: block;
    cursor: zoom-out;
}

.oinf-grid-lb-btn {
    position: absolute;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, .14);
    color: #fff;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    transition: background .2s ease;
}
.oinf-grid-lb-btn:hover { background: rgba(255, 255, 255, .28); }
.oinf-grid-lb-btn.is-close { top: 20px; right: 20px; font-size: 1.4rem; }
.oinf-grid-lb-btn.is-prev  { left: 20px;  top: 50%; transform: translateY(-50%); }
.oinf-grid-lb-btn.is-next  { right: 20px; top: 50%; transform: translateY(-50%); }

@media (prefers-reduced-motion: reduce) {
    .oinf-grid-lb-overlay { transition: none; }
}
